This project enable you to build golang application
Use multi-stage builds with Golang
A OpenID / Keycloak Proxy service written in golang
Official Golang website: The Go Programming Language
Create the smallest and secured golang docker image based on scratch
- keycloak-gatekeeper
- Create docker image with keycloak-gatekeeper
- go-kit (Failed, do not use)
- example of using go-kit
- Install tools from
-
Failed too. go-kit does not seem to support
- https://github.com/go-kit/kit
- https://github.com/GrantZheng/kit (A fork from github.com/kujtimiihoxha/kit) (A medium article talk about this )
- curl https://glide.sh/get | sh (Using A package manager for golang)
- glide init
-
Failed, unmaintained project gokit-cli
- go get github.com/kujtimiihoxha/kit (Unmaintain)
- go get -u google.golang.org/grpc (if you want to utilise generation of gRPC service code)
- go get -u github.com/golang/protobuf/protoc-gen-go (if you want to utilise generation of gRPC service code)
- kit generate service users --dmw (--dmw creates default endpoint middleware, logging middleware.)
- example of using go-kit
- gin-and-gorm-rest-api (based on project )
- Using tableplus, GUI and SQLite3
- Using sqlite3
- import mod from local path
- using go lang viper and godotenv and go env var from medium
- Need to remove the volume by
docker volume ls
anddocker volume rm <uuid>
- The Gorm seem faulty, need to add the key words:
sslmode:disable
, see more info - Great help from here
- Start project
- go mod init
- go mod vendor
- go run main.go
- Deploy into Kubernetes
- Using go mod download to speed up Golang Docker builds
- Using Power environment
docker network create golang-example
docker run -d -e POSTGRES_DB=postgres -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=example --name postgres --network golang-example --mount source=prosgret-vol,destination=/var/lib/postgresql/data -p 5432:5432 postgres:latest
docker run -d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=example -e POSTGRES_DB=postgres -e POSTGRES_HOST=postgres -e POSTGRES_PORT=5432 --network golang-example --name golang-example -p 8080:8080 moxing9876/golang-example:0.0.3
- example output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 9168b3afde13 moxing9876/golang-example:0.0.3 "/go/bin/hello" 4 seconds ago Up 3 seconds 0.0.0.0:8080->8080/tcp golang-example 6949a79586fb postgres:latest "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 0.0.0.0:5432->5432/tcp postgres
$ curl http://localhost:8080/books
- example output :
{"data":[{"id":1,"title":"title1","author":"author1"},{"id":2,"title":"title1","author":"author1"}]}