Hello! We'd love to see your contribution on this repository soon, even if it's just a typo fix!
Contributing means anything from reporting bugs, ideas, suggestion, code fix, even new feature.
Bear in mind to keep your contributions under the Code of Conduct for the community.
The issues page is a great way to communicate to us. Other than that, we have a Telegram group that you can discuss your ideas into. If you're not an Indonesian speaker, it's 100% fine to talk in English there.
Please make sure that the issue you're creating is in as much detail as possible. Poor communication might lead to a big mistake, we're trying to avoid that.
A big heads up before you're writing a breaking change code or a new feature: Please open up an issue regarding what you're working on, or just talk in the Telegram group.
You will need a few things to get things working:
- Latest version of Go (as of now, we're using v1.17.2). You can get it here. For Linux users, you can follow the commands below:
$ wget https://golang.org/dl/go1.17.2.linux-amd64.tar.gz
$ sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.17.2.linux-amd64.tar.gz
$ export PATH=$PATH:/usr/local/go/bin
# Or put it on your ~/.bashrc or equivalent file.
-
MySQL dan Redis database running on your local machine. Also might be achievable through the provided
docker-compose.yml
file. -
Docker and Docker Compose if you want to test the app or run the database servers. (Optional)
- Fork this repository to your own Github account and clone it to your local machine.
- Run
go mod download
to install the dependencies needed. - Get the database up and running. You can use
docker-compose up -d
for this. To stop the container, usedocker-compose stop
. To remove the container, usedocker-compose down
. Bear in mind that the data stored in the Redis and MySQL of the Docker container are not persistent. Once it's stopped, the data will be erased. - You can use Postman, Insomnia or Hoppscotch to create an API request.
- Rename
.env.example
to.env
and fill the config key=value needed. The one's necessary isENVIRONMENT
,PORT
,DATABASE_URL
andREDIS_URL
, you may leave everything else blank. If you're using the Docker Compose file to spin up the database, your.env
should be:
ENVIRONMENT=development
PORT=3000
DATABASE_URL=mysql://root:password@localhost:3306/polarite
REDIS_URL=redis://@localhost:6379/
LOGTAIL_TOKEN=
SENTRY_DSN=
- Run
go run .
to start the development server. - Have fun!
You are encouraged to use Conventional Commit for your commit message. But it's not really compulsory.
We follow Go convention of testing. The test files would be alongside the original file on the same directory. To run the test, do:
$ go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
.
├── business
│ ├── controllers - Business logic
│ └── models - Business model
├── CONTRIBUTING.md - You are here
├── docker-compose.yml - Docker Compose file
├── Dockerfile
├── go.mod
├── go.sum
├── handlers - Route handlers and middleware
├── LICENSE
├── main.go - Main entrypoint (along with app.go)
├── app.go
├── platform - Third-party needs to supplement the app
│ ├── highlight
│ ├── logtail
│ ├── migration
│ └── placeholder.sql - Placeholder data for development
├── README.md
├── repository - Collections of constants and static variables
└── resources - Utilities
Please test (command above) and run Go FMT to pass the CI.
$ go fmt ./...
$ go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
Please note that we don't enforce some kind of convention and patterns like you would see on Java and other languages.
Go code should be boring. And follow Go Proverbs.
And you're set!