Add golangci linters

- Remove unnecessary type conversion.
- Fix gocritic checks.
This commit is contained in:
Gusted 2022-11-15 09:04:56 +01:00
parent df5199c9a3
commit 827c582147
No known key found for this signature in database
GPG key ID: FD821B732837125F
7 changed files with 40 additions and 21 deletions

View file

@ -13,7 +13,7 @@ import (
func (o *Options) GetBranchTimestamp(giteaClient *gitea.Client) (bool, error) {
log := log.With().Strs("BranchInfo", []string{o.TargetOwner, o.TargetRepo, o.TargetBranch}).Logger()
if len(o.TargetBranch) == 0 {
if o.TargetBranch == "" {
// Get default branch
defaultBranch, err := giteaClient.GiteaGetRepoDefaultBranch(o.TargetOwner, o.TargetRepo)
if err != nil {

View file

@ -83,7 +83,7 @@ func (o *Options) Upstream(ctx *context.Context, giteaClient *gitea.Client) (fin
// Check if the browser has a cached version
if ctx.Response() != nil {
if ifModifiedSince, err := time.Parse(time.RFC1123, ctx.Response().Header.Get(headerIfModifiedSince)); err == nil {
if !ifModifiedSince.Before(o.BranchTimestamp) {
if ifModifiedSince.After(o.BranchTimestamp) {
ctx.RespWriter.WriteHeader(http.StatusNotModified)
log.Trace().Msg("check response against last modified: valid")
return true