gobin is a simple lightweight haste-server alternative written in Go, HTML, JS and CSS. It is aimed to be easy to use and deploy. You can find an instance running at xgob.in.
- Easy to deploy and use
- Create, update and delete documents
- Syntax highlighting
- Document expiration
- Supports PostgreSQL or SQLite
- One binary and config file
- Docker image available
The easiest way to deploy gobin is using docker with Docker Compose. You can find the docker image on Packages.
Create a new docker-compose.yml file with the following content:
Note You should change the password in the
docker-compose.ymlandconfig.jsonfile.
version: "3.8"
services:
gobin:
image: ghcr.io/topisenpai/gobin:latest
container_name: gobin
restart: unless-stopped
volumes:
- ./config.json:/var/lib/gobin/config.json
# use this for sqlite
- ./gobin.db:/var/lib/gobin/gobin.db
ports:
- 80:80
# or use this for postgres
postgres:
image: postgres:latest
container_name: postgres
restart: unless-stopped
volumes:
- ./data:/var/lib/postgresql/data
environment:
POSTGRES_DB: gobin
POSTGRES_USER: gobin
POSTGRES_PASSWORD: passwordFor config.json and database see schema Configuration.
docker-compose up -d- Go 1.18 or higher
- PostgreSQL 13 or higher
git clone https://github.com/TopiSenpai/gobin.git
cd gobin
go build -o gobinor
go install github.com/TopiSenpai/gobin@latestgobin --config=config.jsonThe schema is automatically created when you start gobin and there is no documents table in the database.
Create a new config.json file with the following content:
Note Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
{
"listen_addr": "0.0.0.0:80",
"expire_after": "168h",
"cleanup_interval": "10m",
"database": {
# either "postgres" or "sqlite"
"type": "postgres",
# path to sqlite database
# if you run gobin with docker make sure to set it to "/var/lib/gobin/gobin.db"
"path": "gobin.db",
# postgres connection settings
"host": "localhost",
"port": 5432,
"username": "gobin",
"password": "password",
"database": "gobin",
"ssl_mode": "disable"
}
}To create a paste you have to send a POST request to /documents with the content as plain/text body.
Note You can also specify the code language with the
Languageheader.
Language: go
package main
func main() {
println("Hello World!")
}
A successful request will return a 200 OK response with a JSON body containing the document key and token to update the document.
{
"key": "hocwr6i6",
"update_token": "kiczgez33j7qkvqdg9f7ksrd8jk88wba"
}To update a paste you have to send a PATCH request to /documents/{key} with the content as plain/text body and the update_token as Authorization header.
Note You can also specify the code language with the
Languageheader.
Authorization: kiczgez33j7qkvqdg9f7ksrd8jk88wba
Language: go
package main
func main() {
println("Hello World Updated!")
}
A successful request will return a 200 OK response with a JSON body containing the document key and token to update the document.
Note The update token will not change after updating the document. You can use the same token to update the document again.
{
"key": "hocwr6i6",
"update_token": "kiczgez33j7qkvqdg9f7ksrd8jk88wba"
}To delete a paste you have to send a DELETE request to /documents/{key} with the update_token as Authorization header.
gobin is licensed under the Apache License 2.0.
Contributions are always welcome! Just open a pull request or discussion and I will take a look at it.
- @Damon for helping me.