Skip to content

sameterkanboz/golang-service-template

 
 

Golang Service Template

not yet.

Local development

Clone this repository into your projects folder

Installation

  • 1️⃣ Ensure that golang tools are properly installed on your machine

    $ go version
    go version go0.0.0 os/arch64
    
    $ go env GOPATH
    ~/go/0.0.0/packages

    Important rules:

    • GOPATH envvar must be set to output of go env GOPATH
    • $GOPATH/bin must be included to your PATH envvar

    So, your ~/.zprofile should include something like this:

    export GOPATH="$(go env GOPATH)"
    export PATH="$PATH:$GOPATH/bin"
    
  • 2️⃣ Install prerequisites

    • Install golangci-lint
    $ curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
    golangci/golangci-lint info checking GitHub for latest tag
    golangci/golangci-lint info found version: 0.0.0 for v0.0.0/os/arch64
    golangci/golangci-lint info installed ~/go/0.0.0/packages/bin/golangci-lint
    • Install gcov2lcov
    $ go install github.com/jandelgado/gcov2lcov@latest
    • Install pre-commit
    $ brew install pre-commit
    ==> Fetching dependencies for pre-commit
    ==> Fetching pre-commit
    ==> Installing dependencies for pre-commit
    ==> Installing pre-commit
  • 3️⃣ Ensure that you can access private dependencies

    You need to get a Personal Access Token from your GitHub account in order to download private dependencies.

    To get these, visit https://github.com/settings/tokens/new and create a new token with the read:packages scope.

    Then, you need to create or edit the .netrc file in your home directory with the following content:

    machine github.com login <your-github-username> password <your-github-access-token>
    
  • 4️⃣ Download required modules for the project

    $ go mod download
  • 5️⃣ Install pre-commit hooks

    $ pre-commit install

Execution

Running the project in test mode

Before running any command, please make sure that you have configured your environment regarding your own settings first. You may found the related entries that can be configured in .env file.

$ go run ./cmd/service-cli/
[debug] Listening and serving HTTP on :8080

Testing the project

$ go test -v --coverpkg=./... ./...

Development (with Docker Compose)

# first start freshly built containers in background (daemon mode)
$ docker compose up --build -d

# then launch watch mode to reflect changes on time
$ docker compose watch

Contribution

  • Create a new branch for your feature
  • Make your changes
  • Test your changes (see Execution below)
  • Commit your changes
  • Push your changes to your branch
  • Create a pull request to the main branch
  • Wait for review and merge
  • Delete your branch

More Information

This project is bootstrapped from https://github.com/eser/golang-service-template. See the source repository for further details.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 93.0%
  • Makefile 4.8%
  • Dockerfile 2.2%