-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Go init #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| - name: Set up Go | ||
| uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: "1.25" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| go-version: "1.25" | |
| go-version: "1.25.x" |
| run: go build -v ./... | ||
|
|
||
| - name: Check format | ||
| run: go mod tidy && gofmt -s -w . && git diff --exit-code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe easier to use https://github.com/golangci/golangci-lint? It does do even more checks. Example configuration: https://github.com/AikidoSec/firewall-go/blob/main/.golangci.yml
| run: go vet ./... | ||
|
|
||
| - name: Run Tests | ||
| run: go test -v -race -coverprofile=coverage.txt ./... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps nice if it is a separate job? Can of course be changed later.
| - name: Run Tests | ||
| run: go test -v -race -coverprofile=coverage.txt ./... | ||
|
|
||
| frontend: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to frontend PR later so it does not fail here?
| r.Static("/assets", "./frontend/dist/assets") | ||
| r.StaticFile("/", "./frontend/dist/index.html") | ||
| r.NoRoute(func(c *gin.Context) { | ||
| c.File("./frontend/dist/index.html") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The frontend will show a 404 page?
| github.com/gin-gonic/gin v1.11.0 | ||
| github.com/rs/zerolog v1.34.0 | ||
| github.com/spf13/cobra v1.10.2 | ||
| gorm.io/driver/postgres v1.6.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To discuss: only sqlite or both options?
| if strings.HasPrefix(env, "GIN_MODE=") && strings.Contains(env, "release") { | ||
| return true | ||
| } | ||
| if strings.HasPrefix(env, "LOG_FORMAT=") && strings.Contains(env, "json") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check LOG_FORMAT before GIN_MODE? Also add support for setting LOG_FORMAT to another value, e.g. plain.
| // ShoudLogJSON checks if JSON logging should be used based on environment variables and command line arguments | ||
| func ShoudLogJSON(environ []string, args []string) bool { | ||
| // Check for production environment | ||
| for _, env := range environ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why a loop and not LookupEnv?
|
|
||
| // Start server | ||
| addr := fmt.Sprintf(":%s", port) | ||
| fmt.Printf("Server starting on %s\n", addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use logger?
|
|
||
| func CORS() gin.HandlerFunc { | ||
| return cors.New(cors.Config{ | ||
| AllowOrigins: []string{"*"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really secure? We should only allow the public API later? So that it can only be used with API Keys but never with user cookie.
Just the minimal starter