sai-lab / go-template

Template repository for Golang developper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-template

Unit Test Lint Go PkgGoDev

This repository is template repository for golang developper in Saisho labo.

Getting Started

Rename Paramerters

  1. Push use this template button in this repository.
  2. Rename variables for your application. Here's the startup script.
(
    export APPLICATION=your-application-name
    export USER=your-user-name
    export REPOSITORY=$USER/$APPLICATION
    grep -l 'hello' Dockerfile .github/workflows/*.yaml | xargs sed -i.bak -e "s/hello/$APPLICATION/g"
    grep -l 'sai-lab/go-template' * | xargs sed -i.bak -e "s@sai-lab/go-template@$REPOSITORY@g"
    mv cmd/hello cmd/$APPLICATION
)

Setup Container Registry

  1. Get your token for Github Packages. User > Settings > Developper Settins > Personal access tokens > Generate new token Check write:packages and delete:packages after click Generate token.
  2. Copy your token and paste the token set your repository secret variables (name: CR_PAT). Access Your Repository > Settings > Secrets > New Secrets

Docker Build in Local

docker build -t ghcr.io/your-user-name/your-application-name .

Running on Docker

docker run ghcr.io/your-user-name/your-application-name

Local Build

make build

CI

  • Lint (go vet, golangci-lint)
  • Unit Tests
  • Publish library documents
  • Build and push container image to ghcr.io
  • Vulnerability scanning in container image

Lint

Analysis your code staticly when each push.

tools

  • go vet
  • golangci-lint

Publish library documents

Your application documents is generated by GitHub actions when your application released (ref: http://pkg.go.dev).

Build and push container image to ghcr.io

Build and push container image when you tagged a commit. Container image tag format is ghcr.io/{{ owner }}/{{ application }}:{{ version }}.

Vulnerability scanning in container image

Scan Container image when each commits. If vulnerabilities are found, send alert message to your PR.

License

Put your application license.

About

Template repository for Golang developper


Languages

Language:Makefile 52.1%Language:Dockerfile 37.3%Language:Go 10.6%