From cec9cfaf08639c314991955bcd96b6cc79464774 Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 16 Nov 2021 12:18:37 +0100 Subject: [PATCH 1/3] backport: fix golangci-lint warnings - Since https://gitea.com/gitea/test-env/pulls/10 the golangci-lint has been upgraded and is erroring about new warnings in the code, this PR fixes those warnings. --- build.go | 3 ++- build/generate-bindata.go | 1 + build/generate-emoji.go | 1 + build/generate-gitignores.go | 1 + build/generate-licenses.go | 1 + build/gocovmerge.go | 1 + cmd/docs.go | 6 +++++- cmd/embedded.go | 1 + cmd/embedded_stub.go | 1 + models/migrations/migrations.go | 9 ++++++++- modules/auth/pam/pam.go | 1 + modules/auth/pam/pam_stub.go | 1 + modules/auth/pam/pam_test.go | 1 + modules/git/blob_gogit.go | 1 + modules/git/blob_nogogit.go | 1 + modules/git/command_test.go | 1 + modules/git/commit_convert_gogit.go | 1 + modules/git/commit_info_gogit.go | 1 + modules/git/commit_info_nogogit.go | 1 + modules/git/last_commit_cache_gogit.go | 1 + modules/git/last_commit_cache_nogogit.go | 1 + modules/git/notes_gogit.go | 1 + modules/git/notes_nogogit.go | 1 + modules/git/parse_gogit.go | 1 + modules/git/parse_gogit_test.go | 1 + modules/git/parse_nogogit.go | 1 + modules/git/parse_nogogit_test.go | 1 + modules/git/pipeline/lfs.go | 1 + modules/git/pipeline/lfs_nogogit.go | 1 + modules/git/repo_base_gogit.go | 1 + modules/git/repo_base_nogogit.go | 1 + modules/git/repo_blob_gogit.go | 1 + modules/git/repo_blob_nogogit.go | 1 + modules/git/repo_branch_gogit.go | 1 + modules/git/repo_branch_nogogit.go | 1 + modules/git/repo_commit_gogit.go | 1 + modules/git/repo_commit_nogogit.go | 1 + modules/git/repo_commitgraph_gogit.go | 1 + modules/git/repo_language_stats_gogit.go | 1 + modules/git/repo_language_stats_nogogit.go | 1 + modules/git/repo_ref_gogit.go | 1 + modules/git/repo_ref_nogogit.go | 1 + modules/git/repo_tag_gogit.go | 1 + modules/git/repo_tag_nogogit.go | 1 + modules/git/repo_tree_gogit.go | 1 + modules/git/repo_tree_nogogit.go | 1 + modules/git/sha1_gogit.go | 1 + modules/git/sha1_nogogit.go | 1 + modules/git/signature_gogit.go | 1 + modules/git/signature_nogogit.go | 1 + modules/git/submodule.go | 4 +--- modules/git/tree_blob_gogit.go | 1 + modules/git/tree_blob_nogogit.go | 1 + modules/git/tree_entry_gogit.go | 1 + modules/git/tree_entry_nogogit.go | 1 + modules/git/tree_entry_test.go | 1 + modules/git/tree_gogit.go | 1 + modules/git/tree_nogogit.go | 1 + modules/gitgraph/graph_models.go | 8 +++----- modules/graceful/manager_unix.go | 1 + modules/graceful/manager_windows.go | 1 + modules/graceful/net_unix.go | 1 + modules/graceful/net_windows.go | 1 + modules/graceful/restart_unix.go | 1 + modules/indexer/code/bleve.go | 4 ++++ modules/indexer/code/elastic_search.go | 5 ++++- modules/indexer/code/indexer.go | 6 ------ modules/indexer/stats/queue.go | 2 +- modules/lfs/endpoint.go | 4 +--- modules/lfs/pointer_scanner_gogit.go | 1 + modules/lfs/pointer_scanner_nogogit.go | 1 + modules/markup/common/footnote.go | 2 +- modules/options/dynamic.go | 1 + modules/options/options_bindata.go | 3 ++- modules/options/static.go | 1 + modules/public/dynamic.go | 1 + modules/public/public_bindata.go | 3 ++- modules/public/static.go | 1 + modules/repository/adopt.go | 2 +- modules/setting/database_sqlite.go | 1 + modules/svg/discover_bindata.go | 1 + modules/svg/discover_nobindata.go | 1 + modules/templates/dynamic.go | 1 + modules/templates/static.go | 1 + modules/templates/templates_bindata.go | 3 ++- routers/private/manager_unix.go | 1 + routers/private/manager_windows.go | 1 + routers/web/base.go | 8 -------- routers/web/user/setting/adopt.go | 2 +- routers/web/user/setting/profile.go | 2 +- services/auth/placeholder.go | 1 + services/pull/check.go | 2 +- services/pull/merge.go | 4 ++-- services/repository/push.go | 2 +- tools/fuzz.go | 1 + 95 files changed, 117 insertions(+), 41 deletions(-) diff --git a/build.go b/build.go index b843465dca612..aa561413407bc 100644 --- a/build.go +++ b/build.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -//+build vendor +//go:build vendor +// +build vendor package main diff --git a/build/generate-bindata.go b/build/generate-bindata.go index fa1669fcf9fb1..efd172f779aac 100644 --- a/build/generate-bindata.go +++ b/build/generate-bindata.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build ignore // +build ignore package main diff --git a/build/generate-emoji.go b/build/generate-emoji.go index 53c5285b23eca..f8e6498840496 100644 --- a/build/generate-emoji.go +++ b/build/generate-emoji.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build ignore // +build ignore package main diff --git a/build/generate-gitignores.go b/build/generate-gitignores.go index 846bb076365d2..d0b972e803e00 100644 --- a/build/generate-gitignores.go +++ b/build/generate-gitignores.go @@ -1,3 +1,4 @@ +//go:build ignore // +build ignore package main diff --git a/build/generate-licenses.go b/build/generate-licenses.go index 9dd13adf9a7bc..4009a0351d60a 100644 --- a/build/generate-licenses.go +++ b/build/generate-licenses.go @@ -1,3 +1,4 @@ +//go:build ignore // +build ignore package main diff --git a/build/gocovmerge.go b/build/gocovmerge.go index 65d6f2cd6ccc3..b38cf5ea3d5ce 100644 --- a/build/gocovmerge.go +++ b/build/gocovmerge.go @@ -6,6 +6,7 @@ // gocovmerge takes the results from multiple `go test -coverprofile` runs and // merges them into one profile +//go:build ignore // +build ignore package main diff --git a/cmd/docs.go b/cmd/docs.go index 52233c7ac872d..073c57497305f 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -43,7 +43,11 @@ func runDocs(ctx *cli.Context) error { // Clean up markdown. The following bug was fixed in v2, but is present in v1. // It affects markdown output (even though the issue is referring to man pages) // https://github.com/urfave/cli/issues/1040 - docs = docs[strings.Index(docs, "#"):] + firstHashtagIndex := strings.Index(docs, "#") + + if firstHashtagIndex > 0 { + docs = docs[firstHashtagIndex:] + } } out := os.Stdout diff --git a/cmd/embedded.go b/cmd/embedded.go index 528f32402e1a2..2aeaba4786fc4 100644 --- a/cmd/embedded.go +++ b/cmd/embedded.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build bindata // +build bindata package cmd diff --git a/cmd/embedded_stub.go b/cmd/embedded_stub.go index 1f9af7b86b123..0e9e3e6ec3e14 100644 --- a/cmd/embedded_stub.go +++ b/cmd/embedded_stub.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !bindata // +build !bindata package cmd diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 63482ea79037b..dd251a5bcd513 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -7,6 +7,7 @@ package migrations import ( "context" + "errors" "fmt" "os" "reflect" @@ -762,8 +763,14 @@ func dropTableColumns(sess *xorm.Session, tableName string, columnNames ...strin } tableSQL := string(res[0]["sql"]) + // Get the string offset for column definitions: `CREATE TABLE ( column-definitions... )` + columnDefinitionsIndex := strings.Index(tableSQL, "(") + if columnDefinitionsIndex < 0 { + return errors.New("couldn't find column definitions") + } + // Separate out the column definitions - tableSQL = tableSQL[strings.Index(tableSQL, "("):] + tableSQL = tableSQL[columnDefinitionsIndex:] // Remove the required columnNames for _, name := range columnNames { diff --git a/modules/auth/pam/pam.go b/modules/auth/pam/pam.go index f21602c6b5663..6906a9da8970f 100644 --- a/modules/auth/pam/pam.go +++ b/modules/auth/pam/pam.go @@ -1,3 +1,4 @@ +//go:build pam // +build pam // Copyright 2014 The Gogs Authors. All rights reserved. diff --git a/modules/auth/pam/pam_stub.go b/modules/auth/pam/pam_stub.go index 02d8da3c57ad2..a84445639aabf 100644 --- a/modules/auth/pam/pam_stub.go +++ b/modules/auth/pam/pam_stub.go @@ -1,3 +1,4 @@ +//go:build !pam // +build !pam // Copyright 2014 The Gogs Authors. All rights reserved. diff --git a/modules/auth/pam/pam_test.go b/modules/auth/pam/pam_test.go index fa16ff0fe78cd..d6d78a748b7aa 100644 --- a/modules/auth/pam/pam_test.go +++ b/modules/auth/pam/pam_test.go @@ -1,3 +1,4 @@ +//go:build pam // +build pam // Copyright 2021 The Gitea Authors. All rights reserved. diff --git a/modules/git/blob_gogit.go b/modules/git/blob_gogit.go index 7a82eb5c3706f..ef7a90c3f40b8 100644 --- a/modules/git/blob_gogit.go +++ b/modules/git/blob_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/blob_nogogit.go b/modules/git/blob_nogogit.go index f70ecb5333b96..3391bc39311b1 100644 --- a/modules/git/blob_nogogit.go +++ b/modules/git/blob_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/command_test.go b/modules/git/command_test.go index 00801ae31ff25..58d616a0385d5 100644 --- a/modules/git/command_test.go +++ b/modules/git/command_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build race // +build race package git diff --git a/modules/git/commit_convert_gogit.go b/modules/git/commit_convert_gogit.go index be2b948b363f3..b328b3c0edfb7 100644 --- a/modules/git/commit_convert_gogit.go +++ b/modules/git/commit_convert_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/commit_info_gogit.go b/modules/git/commit_info_gogit.go index a8006dcef2e64..8b82f3f66cbae 100644 --- a/modules/git/commit_info_gogit.go +++ b/modules/git/commit_info_gogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/commit_info_nogogit.go b/modules/git/commit_info_nogogit.go index 060ecba26190b..f57355d16ed40 100644 --- a/modules/git/commit_info_nogogit.go +++ b/modules/git/commit_info_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/last_commit_cache_gogit.go b/modules/git/last_commit_cache_gogit.go index b8e0db46a9265..fb09af6f2a762 100644 --- a/modules/git/last_commit_cache_gogit.go +++ b/modules/git/last_commit_cache_gogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/last_commit_cache_nogogit.go b/modules/git/last_commit_cache_nogogit.go index faf6e23fa8166..f71e7350a1fec 100644 --- a/modules/git/last_commit_cache_nogogit.go +++ b/modules/git/last_commit_cache_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/notes_gogit.go b/modules/git/notes_gogit.go index 702754069bd3a..654a52f5f4b8f 100644 --- a/modules/git/notes_gogit.go +++ b/modules/git/notes_gogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/notes_nogogit.go b/modules/git/notes_nogogit.go index 267087a86fafa..f75ab33edd19c 100644 --- a/modules/git/notes_nogogit.go +++ b/modules/git/notes_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/parse_gogit.go b/modules/git/parse_gogit.go index a50ebec3dd72b..c42e32929e457 100644 --- a/modules/git/parse_gogit.go +++ b/modules/git/parse_gogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/parse_gogit_test.go b/modules/git/parse_gogit_test.go index c6374133c0951..c27f5172d5e46 100644 --- a/modules/git/parse_gogit_test.go +++ b/modules/git/parse_gogit_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/parse_nogogit.go b/modules/git/parse_nogogit.go index 667111ec4a313..dd5554b5dd747 100644 --- a/modules/git/parse_nogogit.go +++ b/modules/git/parse_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/parse_nogogit_test.go b/modules/git/parse_nogogit_test.go index 502c38d4e8d9f..5f58237de832e 100644 --- a/modules/git/parse_nogogit_test.go +++ b/modules/git/parse_nogogit_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/pipeline/lfs.go b/modules/git/pipeline/lfs.go index d47b7d91ea86c..46a48b710c6f9 100644 --- a/modules/git/pipeline/lfs.go +++ b/modules/git/pipeline/lfs.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package pipeline diff --git a/modules/git/pipeline/lfs_nogogit.go b/modules/git/pipeline/lfs_nogogit.go index d3696fcda219c..a441e37b60e1e 100644 --- a/modules/git/pipeline/lfs_nogogit.go +++ b/modules/git/pipeline/lfs_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package pipeline diff --git a/modules/git/repo_base_gogit.go b/modules/git/repo_base_gogit.go index 6186824c0b9f6..afa5383b1164b 100644 --- a/modules/git/repo_base_gogit.go +++ b/modules/git/repo_base_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_base_nogogit.go b/modules/git/repo_base_nogogit.go index 1675967d181bc..22c4dfdcb3b8d 100644 --- a/modules/git/repo_base_nogogit.go +++ b/modules/git/repo_base_nogogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/repo_blob_gogit.go b/modules/git/repo_blob_gogit.go index 485c233ff8914..b11e9f58fe9bf 100644 --- a/modules/git/repo_blob_gogit.go +++ b/modules/git/repo_blob_gogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_blob_nogogit.go b/modules/git/repo_blob_nogogit.go index afb08d29cb982..775b3835dd5de 100644 --- a/modules/git/repo_blob_nogogit.go +++ b/modules/git/repo_blob_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/repo_branch_gogit.go b/modules/git/repo_branch_gogit.go index e8386b2dbd98f..6bf14b3999865 100644 --- a/modules/git/repo_branch_gogit.go +++ b/modules/git/repo_branch_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_branch_nogogit.go b/modules/git/repo_branch_nogogit.go index 7d10b8ba0faeb..666ca81c1e8f8 100644 --- a/modules/git/repo_branch_nogogit.go +++ b/modules/git/repo_branch_nogogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/repo_commit_gogit.go b/modules/git/repo_commit_gogit.go index 2f9b1c4206f42..175b6e644660c 100644 --- a/modules/git/repo_commit_gogit.go +++ b/modules/git/repo_commit_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_commit_nogogit.go b/modules/git/repo_commit_nogogit.go index afd5166f1d549..b7e49a6501b17 100644 --- a/modules/git/repo_commit_nogogit.go +++ b/modules/git/repo_commit_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/repo_commitgraph_gogit.go b/modules/git/repo_commitgraph_gogit.go index 67731094513cc..84a2edb664bb4 100644 --- a/modules/git/repo_commitgraph_gogit.go +++ b/modules/git/repo_commitgraph_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_language_stats_gogit.go b/modules/git/repo_language_stats_gogit.go index 20a7b061f2107..0a4cfbbc7bfb9 100644 --- a/modules/git/repo_language_stats_gogit.go +++ b/modules/git/repo_language_stats_gogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_language_stats_nogogit.go b/modules/git/repo_language_stats_nogogit.go index 1684f21d1675d..7425e2dbb1d1b 100644 --- a/modules/git/repo_language_stats_nogogit.go +++ b/modules/git/repo_language_stats_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/repo_ref_gogit.go b/modules/git/repo_ref_gogit.go index 2e83e6c4627be..9f0e11366f677 100644 --- a/modules/git/repo_ref_gogit.go +++ b/modules/git/repo_ref_gogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_ref_nogogit.go b/modules/git/repo_ref_nogogit.go index 540961592b4c0..ec0c5ec4cad30 100644 --- a/modules/git/repo_ref_nogogit.go +++ b/modules/git/repo_ref_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/repo_tag_gogit.go b/modules/git/repo_tag_gogit.go index 3ac097c9a8c2c..3022fe96f7772 100644 --- a/modules/git/repo_tag_gogit.go +++ b/modules/git/repo_tag_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_tag_nogogit.go b/modules/git/repo_tag_nogogit.go index a9e122aeaa7d6..0170f0cc76e7d 100644 --- a/modules/git/repo_tag_nogogit.go +++ b/modules/git/repo_tag_nogogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/repo_tree_gogit.go b/modules/git/repo_tree_gogit.go index d878f5e7a7258..2ddffcf79b679 100644 --- a/modules/git/repo_tree_gogit.go +++ b/modules/git/repo_tree_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/repo_tree_nogogit.go b/modules/git/repo_tree_nogogit.go index 967f8aea3f44d..9d4268b13a286 100644 --- a/modules/git/repo_tree_nogogit.go +++ b/modules/git/repo_tree_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/sha1_gogit.go b/modules/git/sha1_gogit.go index 5953af58bfcc3..30290f14b7385 100644 --- a/modules/git/sha1_gogit.go +++ b/modules/git/sha1_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/sha1_nogogit.go b/modules/git/sha1_nogogit.go index 09b5baacd5c98..53665fc9217d3 100644 --- a/modules/git/sha1_nogogit.go +++ b/modules/git/sha1_nogogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/signature_gogit.go b/modules/git/signature_gogit.go index 804c0074d351c..903a48133f80d 100644 --- a/modules/git/signature_gogit.go +++ b/modules/git/signature_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/signature_nogogit.go b/modules/git/signature_nogogit.go index 753d87b6059f1..c6fe8e6d1a99e 100644 --- a/modules/git/signature_nogogit.go +++ b/modules/git/signature_nogogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/submodule.go b/modules/git/submodule.go index 231827f1e989a..ee61f6117970e 100644 --- a/modules/git/submodule.go +++ b/modules/git/submodule.go @@ -52,9 +52,7 @@ func getRefURL(refURL, urlPrefix, repoFullName, sshDomain string) string { urlPrefixHostname = prefixURL.Host } - if strings.HasSuffix(urlPrefix, "/") { - urlPrefix = urlPrefix[:len(urlPrefix)-1] - } + urlPrefix = strings.TrimSuffix(urlPrefix, "/") // FIXME: Need to consider branch - which will require changes in modules/git/commit.go:GetSubModules // Relative url prefix check (according to git submodule documentation) diff --git a/modules/git/tree_blob_gogit.go b/modules/git/tree_blob_gogit.go index 93ebc8a367da4..a8d619cd18ed6 100644 --- a/modules/git/tree_blob_gogit.go +++ b/modules/git/tree_blob_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/tree_blob_nogogit.go b/modules/git/tree_blob_nogogit.go index fdd8d79c8b632..df23ff01b474b 100644 --- a/modules/git/tree_blob_nogogit.go +++ b/modules/git/tree_blob_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/tree_entry_gogit.go b/modules/git/tree_entry_gogit.go index 219251a77e42c..20e767eea1f72 100644 --- a/modules/git/tree_entry_gogit.go +++ b/modules/git/tree_entry_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/tree_entry_nogogit.go b/modules/git/tree_entry_nogogit.go index 41356ceba2326..288ec4db6e194 100644 --- a/modules/git/tree_entry_nogogit.go +++ b/modules/git/tree_entry_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/git/tree_entry_test.go b/modules/git/tree_entry_test.go index 3382de41028d6..402c345887f8d 100644 --- a/modules/git/tree_entry_test.go +++ b/modules/git/tree_entry_test.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/tree_gogit.go b/modules/git/tree_gogit.go index 79132c5548a92..bc020883660d7 100644 --- a/modules/git/tree_gogit.go +++ b/modules/git/tree_gogit.go @@ -3,6 +3,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package git diff --git a/modules/git/tree_nogogit.go b/modules/git/tree_nogogit.go index 9661d8faea158..3d3fd26ece768 100644 --- a/modules/git/tree_nogogit.go +++ b/modules/git/tree_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package git diff --git a/modules/gitgraph/graph_models.go b/modules/gitgraph/graph_models.go index ec47f0ad84aca..5ed264232882f 100644 --- a/modules/gitgraph/graph_models.go +++ b/modules/gitgraph/graph_models.go @@ -217,11 +217,9 @@ func newRefsFromRefNames(refNames []byte) []git.Reference { continue } refName := string(refNameBytes) - if strings.HasPrefix(refName, "tag: ") { - refName = strings.TrimPrefix(refName, "tag: ") - } else if strings.HasPrefix(refName, "HEAD -> ") { - refName = strings.TrimPrefix(refName, "HEAD -> ") - } + refName = strings.TrimPrefix(refName, "tag: ") + refName = strings.TrimPrefix(refName, "HEAD -> ") + refs = append(refs, git.Reference{ Name: refName, }) diff --git a/modules/graceful/manager_unix.go b/modules/graceful/manager_unix.go index 20d9b3905c4fb..41ab521b7231d 100644 --- a/modules/graceful/manager_unix.go +++ b/modules/graceful/manager_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows // Copyright 2019 The Gitea Authors. All rights reserved. diff --git a/modules/graceful/manager_windows.go b/modules/graceful/manager_windows.go index 51f29778ba7af..3388ccf881cc7 100644 --- a/modules/graceful/manager_windows.go +++ b/modules/graceful/manager_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows // Copyright 2019 The Gitea Authors. All rights reserved. diff --git a/modules/graceful/net_unix.go b/modules/graceful/net_unix.go index 2dc714955e1ed..e8f96aa80d1d4 100644 --- a/modules/graceful/net_unix.go +++ b/modules/graceful/net_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows // Copyright 2019 The Gitea Authors. All rights reserved. diff --git a/modules/graceful/net_windows.go b/modules/graceful/net_windows.go index 3fc14334912a0..75cd81dac4476 100644 --- a/modules/graceful/net_windows.go +++ b/modules/graceful/net_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows // Copyright 2019 The Gitea Authors. All rights reserved. diff --git a/modules/graceful/restart_unix.go b/modules/graceful/restart_unix.go index 9a94e5fa677bd..1bd120dcf6a2c 100644 --- a/modules/graceful/restart_unix.go +++ b/modules/graceful/restart_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows // Copyright 2019 The Gitea Authors. All rights reserved. diff --git a/modules/indexer/code/bleve.go b/modules/indexer/code/bleve.go index fc5c602dbef08..4f8ced623214a 100644 --- a/modules/indexer/code/bleve.go +++ b/modules/indexer/code/bleve.go @@ -174,6 +174,10 @@ func NewBleveIndexer(indexDir string) (*BleveIndexer, bool, error) { indexDir: indexDir, } created, err := indexer.init() + if err != nil { + indexer.Close() + return nil, false, err + } return indexer, created, err } diff --git a/modules/indexer/code/elastic_search.go b/modules/indexer/code/elastic_search.go index 569917f151f49..9e5fe506e5e24 100644 --- a/modules/indexer/code/elastic_search.go +++ b/modules/indexer/code/elastic_search.go @@ -83,7 +83,10 @@ func NewElasticSearchIndexer(url, indexerName string) (*ElasticSearchIndexer, bo indexerAliasName: indexerName, } exists, err := indexer.init() - + if err != nil { + indexer.Close() + return nil, false, err + } return indexer, !exists, err } diff --git a/modules/indexer/code/indexer.go b/modules/indexer/code/indexer.go index 67fa43eda89dc..f81d9abb9408e 100644 --- a/modules/indexer/code/indexer.go +++ b/modules/indexer/code/indexer.go @@ -188,9 +188,6 @@ func Init() { rIndexer, populate, err = NewBleveIndexer(setting.Indexer.RepoPath) if err != nil { - if rIndexer != nil { - rIndexer.Close() - } cancel() indexer.Close() close(waitChannel) @@ -208,9 +205,6 @@ func Init() { rIndexer, populate, err = NewElasticSearchIndexer(setting.Indexer.RepoConnStr, setting.Indexer.RepoIndexerName) if err != nil { - if rIndexer != nil { - rIndexer.Close() - } cancel() indexer.Close() close(waitChannel) diff --git a/modules/indexer/stats/queue.go b/modules/indexer/stats/queue.go index 8309cfcd3bc4e..fde3f2ff01072 100644 --- a/modules/indexer/stats/queue.go +++ b/modules/indexer/stats/queue.go @@ -27,7 +27,7 @@ func handle(data ...queue.Data) { } func initStatsQueue() error { - statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0)).(queue.UniqueQueue) + statsQueue = queue.CreateUniqueQueue("repo_stats_update", handle, int64(0)) if statsQueue == nil { return fmt.Errorf("Unable to create repo_stats_update Queue") } diff --git a/modules/lfs/endpoint.go b/modules/lfs/endpoint.go index add16ce9f12ec..943966ed15592 100644 --- a/modules/lfs/endpoint.go +++ b/modules/lfs/endpoint.go @@ -29,9 +29,7 @@ func endpointFromCloneURL(rawurl string) *url.URL { return ep } - if strings.HasSuffix(ep.Path, "/") { - ep.Path = ep.Path[:len(ep.Path)-1] - } + ep.Path = strings.TrimSuffix(ep.Path, "/") if ep.Scheme == "file" { return ep diff --git a/modules/lfs/pointer_scanner_gogit.go b/modules/lfs/pointer_scanner_gogit.go index abd882990c137..7e8b812f466de 100644 --- a/modules/lfs/pointer_scanner_gogit.go +++ b/modules/lfs/pointer_scanner_gogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gogit // +build gogit package lfs diff --git a/modules/lfs/pointer_scanner_nogogit.go b/modules/lfs/pointer_scanner_nogogit.go index b5654d5de751e..d8076b90216f2 100644 --- a/modules/lfs/pointer_scanner_nogogit.go +++ b/modules/lfs/pointer_scanner_nogogit.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !gogit // +build !gogit package lfs diff --git a/modules/markup/common/footnote.go b/modules/markup/common/footnote.go index 9baf8a4998b7c..a4be013250cdc 100644 --- a/modules/markup/common/footnote.go +++ b/modules/markup/common/footnote.go @@ -126,7 +126,7 @@ type Footnote struct { func (n *Footnote) Dump(source []byte, level int) { m := map[string]string{} m["Index"] = fmt.Sprintf("%v", n.Index) - m["Ref"] = fmt.Sprintf("%s", n.Ref) + m["Ref"] = string(n.Ref) m["Name"] = fmt.Sprintf("%v", n.Name) ast.DumpHelper(n, source, level, m, nil) } diff --git a/modules/options/dynamic.go b/modules/options/dynamic.go index ffb89df88274b..32d3f52eaa35f 100644 --- a/modules/options/dynamic.go +++ b/modules/options/dynamic.go @@ -1,3 +1,4 @@ +//go:build !bindata // +build !bindata // Copyright 2016 The Gitea Authors. All rights reserved. diff --git a/modules/options/options_bindata.go b/modules/options/options_bindata.go index 262bd0de3e093..64da772c6fbb3 100644 --- a/modules/options/options_bindata.go +++ b/modules/options/options_bindata.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -//+build bindata +//go:build bindata +// +build bindata package options diff --git a/modules/options/static.go b/modules/options/static.go index 5f4ffdda78e49..e6a4454b7debc 100644 --- a/modules/options/static.go +++ b/modules/options/static.go @@ -1,3 +1,4 @@ +//go:build bindata // +build bindata // Copyright 2016 The Gitea Authors. All rights reserved. diff --git a/modules/public/dynamic.go b/modules/public/dynamic.go index 0bfe38bc3f3f1..c25bab979ff98 100644 --- a/modules/public/dynamic.go +++ b/modules/public/dynamic.go @@ -1,3 +1,4 @@ +//go:build !bindata // +build !bindata // Copyright 2016 The Gitea Authors. All rights reserved. diff --git a/modules/public/public_bindata.go b/modules/public/public_bindata.go index 05648aea80939..eb10d96426bf1 100644 --- a/modules/public/public_bindata.go +++ b/modules/public/public_bindata.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -//+build bindata +//go:build bindata +// +build bindata package public diff --git a/modules/public/static.go b/modules/public/static.go index 827dc2a1e0e8d..1e5853961f0b4 100644 --- a/modules/public/static.go +++ b/modules/public/static.go @@ -1,3 +1,4 @@ +//go:build bindata // +build bindata // Copyright 2016 The Gitea Authors. All rights reserved. diff --git a/modules/repository/adopt.go b/modules/repository/adopt.go index cdcf7104e0416..fe23bdf5e7b07 100644 --- a/modules/repository/adopt.go +++ b/modules/repository/adopt.go @@ -152,7 +152,7 @@ func ListUnadoptedRepositories(query string, opts *models.ListOptions) ([]string count := 0 // We're going to iterate by pagesize. - root := filepath.Join(setting.RepoRootPath) + root := filepath.Clean(setting.RepoRootPath) if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { if err != nil { return err diff --git a/modules/setting/database_sqlite.go b/modules/setting/database_sqlite.go index 623326ddc2fc1..798292fec86bc 100644 --- a/modules/setting/database_sqlite.go +++ b/modules/setting/database_sqlite.go @@ -1,3 +1,4 @@ +//go:build sqlite // +build sqlite // Copyright 2014 The Gogs Authors. All rights reserved. diff --git a/modules/svg/discover_bindata.go b/modules/svg/discover_bindata.go index 1f7af0c9f89d5..e11951ff7ec97 100644 --- a/modules/svg/discover_bindata.go +++ b/modules/svg/discover_bindata.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build bindata // +build bindata package svg diff --git a/modules/svg/discover_nobindata.go b/modules/svg/discover_nobindata.go index d667da2d660ca..8d857551dc47e 100644 --- a/modules/svg/discover_nobindata.go +++ b/modules/svg/discover_nobindata.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !bindata // +build !bindata package svg diff --git a/modules/templates/dynamic.go b/modules/templates/dynamic.go index 160e4e05f2501..8e083408d01c2 100644 --- a/modules/templates/dynamic.go +++ b/modules/templates/dynamic.go @@ -1,3 +1,4 @@ +//go:build !bindata // +build !bindata // Copyright 2016 The Gitea Authors. All rights reserved. diff --git a/modules/templates/static.go b/modules/templates/static.go index 7f95d77ad3242..27449f926db65 100644 --- a/modules/templates/static.go +++ b/modules/templates/static.go @@ -1,3 +1,4 @@ +//go:build bindata // +build bindata // Copyright 2016 The Gitea Authors. All rights reserved. diff --git a/modules/templates/templates_bindata.go b/modules/templates/templates_bindata.go index 5a59286c7a98a..887f9eeba25b9 100644 --- a/modules/templates/templates_bindata.go +++ b/modules/templates/templates_bindata.go @@ -2,7 +2,8 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. -//+build bindata +//go:build bindata +// +build bindata package templates diff --git a/routers/private/manager_unix.go b/routers/private/manager_unix.go index 60ae9b68e82ca..84e6e60126cd8 100644 --- a/routers/private/manager_unix.go +++ b/routers/private/manager_unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows // Copyright 2020 The Gitea Authors. All rights reserved. diff --git a/routers/private/manager_windows.go b/routers/private/manager_windows.go index f6c9b7ec8ff25..312a0ef22016e 100644 --- a/routers/private/manager_windows.go +++ b/routers/private/manager_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows // Copyright 2020 The Gitea Authors. All rights reserved. diff --git a/routers/web/base.go b/routers/web/base.go index af55cb4e97f63..5a0e528f93d1c 100644 --- a/routers/web/base.go +++ b/routers/web/base.go @@ -130,14 +130,6 @@ func Recovery() func(next http.Handler) http.Handler { log.Error("%v", combinedErr) sessionStore := session.GetSession(req) - if sessionStore == nil { - if setting.IsProd() { - http.Error(w, http.StatusText(500), 500) - } else { - http.Error(w, combinedErr, 500) - } - return - } var lc = middleware.Locale(w, req) var store = dataStore{ diff --git a/routers/web/user/setting/adopt.go b/routers/web/user/setting/adopt.go index b2d918784f59a..509418717d212 100644 --- a/routers/web/user/setting/adopt.go +++ b/routers/web/user/setting/adopt.go @@ -27,7 +27,7 @@ func AdoptOrDeleteRepository(ctx *context.Context) { action := ctx.Query("action") ctxUser := ctx.User - root := filepath.Join(models.UserPath(ctxUser.LowerName)) + root := models.UserPath(ctxUser.LowerName) // check not a repo has, err := models.IsRepositoryExist(ctxUser, dir) diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 682f9205784e3..8ea726a49970a 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -246,7 +246,7 @@ func Repos(ctx *context.Context) { repoNames := make([]string, 0, setting.UI.Admin.UserPagingNum) repos := map[string]*models.Repository{} // We're going to iterate by pagesize. - root := filepath.Join(models.UserPath(ctxUser.Name)) + root := models.UserPath(ctxUser.Name) if err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { if err != nil { if os.IsNotExist(err) { diff --git a/services/auth/placeholder.go b/services/auth/placeholder.go index 50e3061885f80..d9a0ceae7c45a 100644 --- a/services/auth/placeholder.go +++ b/services/auth/placeholder.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !windows // +build !windows package auth diff --git a/services/pull/check.go b/services/pull/check.go index 1e757ef28b229..7d365e1223918 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -254,7 +254,7 @@ func CheckPrsForBaseBranch(baseRepo *models.Repository, baseBranchName string) e // Init runs the task queue to test all the checking status pull requests func Init() error { - prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "").(queue.UniqueQueue) + prQueue = queue.CreateUniqueQueue("pr_patch_checker", handle, "") if prQueue == nil { return fmt.Errorf("Unable to create pr_patch_checker Queue") diff --git a/services/pull/merge.go b/services/pull/merge.go index 7e6a214b87d92..8c0eeadd792e7 100644 --- a/services/pull/merge.go +++ b/services/pull/merge.go @@ -273,8 +273,8 @@ func rawMerge(pr *models.PullRequest, doer *models.User, mergeStyle models.Merge filepath.Join(tmpBasePath, ".git", "rebase-merge", "stopped-sha"), // Git >= 2.26 } for _, failingCommitPath := range failingCommitPaths { - if _, statErr := os.Stat(filepath.Join(failingCommitPath)); statErr == nil { - commitShaBytes, readErr := ioutil.ReadFile(filepath.Join(failingCommitPath)) + if _, statErr := os.Stat(failingCommitPath); statErr == nil { + commitShaBytes, readErr := ioutil.ReadFile(failingCommitPath) if readErr != nil { // Abandon this attempt to handle the error log.Error("git rebase staging on to base [%s:%s -> %s:%s]: %v\n%s\n%s", pr.HeadRepo.FullName(), pr.HeadBranch, pr.BaseRepo.FullName(), pr.BaseBranch, err, outbuf.String(), errbuf.String()) diff --git a/services/repository/push.go b/services/repository/push.go index 26df6b8e45e66..03e292757a345 100644 --- a/services/repository/push.go +++ b/services/repository/push.go @@ -36,7 +36,7 @@ func handle(data ...queue.Data) { } func initPushQueue() error { - pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{}).(queue.Queue) + pushQueue = queue.CreateQueue("push_update", handle, []*repo_module.PushUpdateOptions{}) if pushQueue == nil { return fmt.Errorf("Unable to create push_update Queue") } diff --git a/tools/fuzz.go b/tools/fuzz.go index ca35ff4f00826..2f980b3b895fd 100644 --- a/tools/fuzz.go +++ b/tools/fuzz.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build gofuzz // +build gofuzz package fuzz From 49fbe751f677589283d0e458f39ad950b7a06f32 Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 16 Nov 2021 13:37:38 +0100 Subject: [PATCH 2/3] Fix build not passing --- .golangci.yml | 1 - modules/auth/pam/pam_stub.go | 6 +++--- modules/graceful/manager_unix.go | 6 +++--- modules/graceful/net_unix.go | 6 +++--- modules/graceful/restart_unix.go | 6 +++--- modules/options/dynamic.go | 6 +++--- modules/public/dynamic.go | 6 +++--- modules/templates/dynamic.go | 6 +++--- routers/private/manager_unix.go | 6 +++--- 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c3dd47ec29da6..6e7aa750f7f08 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,7 +9,6 @@ linters: - unused - structcheck - varcheck - - golint - dupl #- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time. - gofmt diff --git a/modules/auth/pam/pam_stub.go b/modules/auth/pam/pam_stub.go index a84445639aabf..815ccf2b0e2db 100644 --- a/modules/auth/pam/pam_stub.go +++ b/modules/auth/pam/pam_stub.go @@ -1,10 +1,10 @@ -//go:build !pam -// +build !pam - // Copyright 2014 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !pam +// +build !pam + package pam import ( diff --git a/modules/graceful/manager_unix.go b/modules/graceful/manager_unix.go index 41ab521b7231d..fcbb16a3bb96f 100644 --- a/modules/graceful/manager_unix.go +++ b/modules/graceful/manager_unix.go @@ -1,10 +1,10 @@ -//go:build !windows -// +build !windows - // Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !windows +// +build !windows + package graceful import ( diff --git a/modules/graceful/net_unix.go b/modules/graceful/net_unix.go index e8f96aa80d1d4..6ffa8150cc1a4 100644 --- a/modules/graceful/net_unix.go +++ b/modules/graceful/net_unix.go @@ -1,11 +1,11 @@ -//go:build !windows -// +build !windows - // Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler +//go:build !windows +// +build !windows + package graceful import ( diff --git a/modules/graceful/restart_unix.go b/modules/graceful/restart_unix.go index 1bd120dcf6a2c..392ed60cb381b 100644 --- a/modules/graceful/restart_unix.go +++ b/modules/graceful/restart_unix.go @@ -1,11 +1,11 @@ -//go:build !windows -// +build !windows - // Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler +//go:build !windows +// +build !windows + package graceful import ( diff --git a/modules/options/dynamic.go b/modules/options/dynamic.go index 32d3f52eaa35f..13fa5d6aa7ebd 100644 --- a/modules/options/dynamic.go +++ b/modules/options/dynamic.go @@ -1,10 +1,10 @@ -//go:build !bindata -// +build !bindata - // Copyright 2016 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !bindata +// +build !bindata + package options import ( diff --git a/modules/public/dynamic.go b/modules/public/dynamic.go index c25bab979ff98..955c01e510313 100644 --- a/modules/public/dynamic.go +++ b/modules/public/dynamic.go @@ -1,10 +1,10 @@ -//go:build !bindata -// +build !bindata - // Copyright 2016 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !bindata +// +build !bindata + package public import ( diff --git a/modules/templates/dynamic.go b/modules/templates/dynamic.go index 8e083408d01c2..4732fce421fa7 100644 --- a/modules/templates/dynamic.go +++ b/modules/templates/dynamic.go @@ -1,10 +1,10 @@ -//go:build !bindata -// +build !bindata - // Copyright 2016 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !bindata +// +build !bindata + package templates import ( diff --git a/routers/private/manager_unix.go b/routers/private/manager_unix.go index 84e6e60126cd8..1738c06a05fb0 100644 --- a/routers/private/manager_unix.go +++ b/routers/private/manager_unix.go @@ -1,10 +1,10 @@ -//go:build !windows -// +build !windows - // Copyright 2020 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build !windows +// +build !windows + package private import ( From 544df73611f65c3d10bc72ab2a45c42eb86de3ba Mon Sep 17 00:00:00 2001 From: Gusted Date: Tue, 16 Nov 2021 16:16:21 +0100 Subject: [PATCH 3/3] Fix linting on windows --- modules/graceful/manager_windows.go | 6 +++--- modules/graceful/net_windows.go | 6 +++--- routers/private/manager_windows.go | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/graceful/manager_windows.go b/modules/graceful/manager_windows.go index 3388ccf881cc7..e5f5541ed3c3c 100644 --- a/modules/graceful/manager_windows.go +++ b/modules/graceful/manager_windows.go @@ -1,11 +1,11 @@ -//go:build windows -// +build windows - // Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler +//go:build windows +// +build windows + package graceful import ( diff --git a/modules/graceful/net_windows.go b/modules/graceful/net_windows.go index 75cd81dac4476..35b7a9d1feae3 100644 --- a/modules/graceful/net_windows.go +++ b/modules/graceful/net_windows.go @@ -1,11 +1,11 @@ -//go:build windows -// +build windows - // Copyright 2019 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. // This code is heavily inspired by the archived gofacebook/gracenet/net.go handler +//go:build windows +// +build windows + package graceful import "net" diff --git a/routers/private/manager_windows.go b/routers/private/manager_windows.go index 312a0ef22016e..a8a477313fb02 100644 --- a/routers/private/manager_windows.go +++ b/routers/private/manager_windows.go @@ -1,10 +1,10 @@ -//go:build windows -// +build windows - // Copyright 2020 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. +//go:build windows +// +build windows + package private import (