summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-01-20 18:46:10 +0100
committerGitHub <noreply@github.com>2022-01-20 18:46:10 +0100
commit54e9ee37a7a301dbe74d46fd3c87712e6120e9bf (patch)
tree1be12fb072625c1b896b9d72f7912b018aad502b /build
parent1d98d205f5825f40110e6628b61a97c91ac7f72d (diff)
downloadgitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.tar.gz
gitea-54e9ee37a7a301dbe74d46fd3c87712e6120e9bf.zip
format with gofumpt (#18184)
* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
Diffstat (limited to 'build')
-rw-r--r--build/code-batch-process.go2
-rw-r--r--build/codeformat/formatimports.go16
-rw-r--r--build/generate-bindata.go5
-rw-r--r--build/generate-emoji.go12
-rw-r--r--build/generate-gitignores.go5
-rw-r--r--build/generate-licenses.go3
-rw-r--r--build/gocovmerge.go2
7 files changed, 20 insertions, 25 deletions
diff --git a/build/code-batch-process.go b/build/code-batch-process.go
index 1fd236abd5..02f54b9c0a 100644
--- a/build/code-batch-process.go
+++ b/build/code-batch-process.go
@@ -136,7 +136,7 @@ func (fc *fileCollector) collectFiles() (res [][]string, err error) {
}
// substArgFiles expands the {file-list} to a real file list for commands
-func substArgFiles(args []string, files []string) []string {
+func substArgFiles(args, files []string) []string {
for i, s := range args {
if s == "{file-list}" {
newArgs := append(args[:i], files...)
diff --git a/build/codeformat/formatimports.go b/build/codeformat/formatimports.go
index c6427f6a99..fedc5cc090 100644
--- a/build/codeformat/formatimports.go
+++ b/build/codeformat/formatimports.go
@@ -20,8 +20,10 @@ var importPackageGroupOrders = map[string]int{
var errInvalidCommentBetweenImports = errors.New("comments between imported packages are invalid, please move comments to the end of the package line")
-var importBlockBegin = []byte("\nimport (\n")
-var importBlockEnd = []byte("\n)")
+var (
+ importBlockBegin = []byte("\nimport (\n")
+ importBlockEnd = []byte("\n)")
+)
type importLineParsed struct {
group string
@@ -59,8 +61,10 @@ func parseImportLine(line string) (*importLineParsed, error) {
return il, nil
}
-type importLineGroup []*importLineParsed
-type importLineGroupMap map[string]importLineGroup
+type (
+ importLineGroup []*importLineParsed
+ importLineGroupMap map[string]importLineGroup
+)
func formatGoImports(contentBytes []byte) ([]byte, error) {
p1 := bytes.Index(contentBytes, importBlockBegin)
@@ -153,7 +157,7 @@ func formatGoImports(contentBytes []byte) ([]byte, error) {
return formattedBytes, nil
}
-//FormatGoImports format the imports by our rules (see unit tests)
+// FormatGoImports format the imports by our rules (see unit tests)
func FormatGoImports(file string) error {
f, err := os.Open(file)
if err != nil {
@@ -177,7 +181,7 @@ func FormatGoImports(file string) error {
if bytes.Equal(contentBytes, formattedBytes) {
return nil
}
- f, err = os.OpenFile(file, os.O_TRUNC|os.O_WRONLY, 0644)
+ f, err = os.OpenFile(file, os.O_TRUNC|os.O_WRONLY, 0o644)
if err != nil {
return err
}
diff --git a/build/generate-bindata.go b/build/generate-bindata.go
index 7941af60a1..7fdf9d7616 100644
--- a/build/generate-bindata.go
+++ b/build/generate-bindata.go
@@ -20,7 +20,7 @@ import (
"github.com/shurcooL/vfsgen"
)
-func needsUpdate(dir string, filename string) (bool, []byte) {
+func needsUpdate(dir, filename string) (bool, []byte) {
needRegen := false
_, err := os.Stat(filename)
if err != nil {
@@ -50,7 +50,6 @@ func needsUpdate(dir string, filename string) (bool, []byte) {
newHash := hasher.Sum([]byte{})
if bytes.Compare(oldHash, newHash) != 0 {
-
return true, newHash
}
@@ -87,5 +86,5 @@ func main() {
if err != nil {
log.Fatalf("%v\n", err)
}
- _ = os.WriteFile(filename+".hash", newHash, 0666)
+ _ = os.WriteFile(filename+".hash", newHash, 0o666)
}
diff --git a/build/generate-emoji.go b/build/generate-emoji.go
index aa56d45f74..2f3536342d 100644
--- a/build/generate-emoji.go
+++ b/build/generate-emoji.go
@@ -30,9 +30,7 @@ const (
maxUnicodeVersion = 12
)
-var (
- flagOut = flag.String("o", "modules/emoji/emoji_data.go", "out")
-)
+var flagOut = flag.String("o", "modules/emoji/emoji_data.go", "out")
// Gemoji is a set of emoji data.
type Gemoji []Emoji
@@ -68,7 +66,7 @@ func main() {
}
// write
- err = os.WriteFile(*flagOut, buf, 0644)
+ err = os.WriteFile(*flagOut, buf, 0o644)
if err != nil {
log.Fatal(err)
}
@@ -109,7 +107,7 @@ func generate() ([]byte, error) {
return nil, err
}
- var skinTones = make(map[string]string)
+ skinTones := make(map[string]string)
skinTones["\U0001f3fb"] = "Light Skin Tone"
skinTones["\U0001f3fc"] = "Medium-Light Skin Tone"
@@ -119,7 +117,7 @@ func generate() ([]byte, error) {
var tmp Gemoji
- //filter out emoji that require greater than max unicode version
+ // filter out emoji that require greater than max unicode version
for i := range data {
val, _ := strconv.ParseFloat(data[i].UnicodeVersion, 64)
if int(val) <= maxUnicodeVersion {
@@ -158,7 +156,7 @@ func generate() ([]byte, error) {
// write a JSON file to use with tribute (write before adding skin tones since we can't support them there yet)
file, _ := json.Marshal(data)
- _ = os.WriteFile("assets/emoji.json", file, 0644)
+ _ = os.WriteFile("assets/emoji.json", file, 0o644)
// Add skin tones to emoji that support it
var (
diff --git a/build/generate-gitignores.go b/build/generate-gitignores.go
index 811953ee4a..0f7d719d40 100644
--- a/build/generate-gitignores.go
+++ b/build/generate-gitignores.go
@@ -34,7 +34,6 @@ func main() {
flag.Parse()
file, err := os.CreateTemp(os.TempDir(), prefix)
-
if err != nil {
log.Fatalf("Failed to create temp file. %s", err)
}
@@ -65,7 +64,6 @@ func main() {
}
gz, err := gzip.NewReader(file)
-
if err != nil {
log.Fatalf("Failed to gunzip the archive. %s", err)
}
@@ -96,7 +94,6 @@ func main() {
}
out, err := os.Create(path.Join(destination, strings.TrimSuffix(filepath.Base(hdr.Name), ".gitignore")))
-
if err != nil {
log.Fatalf("Failed to create new file. %s", err)
}
@@ -119,7 +116,7 @@ func main() {
}
// Write data to dst
dst = path.Join(destination, dst)
- err = os.WriteFile(dst, data, 0644)
+ err = os.WriteFile(dst, data, 0o644)
if err != nil {
log.Fatalf("Failed to write new file. %s", err)
}
diff --git a/build/generate-licenses.go b/build/generate-licenses.go
index 75fb7cc810..0f9b9f369f 100644
--- a/build/generate-licenses.go
+++ b/build/generate-licenses.go
@@ -34,7 +34,6 @@ func main() {
flag.Parse()
file, err := os.CreateTemp(os.TempDir(), prefix)
-
if err != nil {
log.Fatalf("Failed to create temp file. %s", err)
}
@@ -66,7 +65,6 @@ func main() {
}
gz, err := gzip.NewReader(file)
-
if err != nil {
log.Fatalf("Failed to gunzip the archive. %s", err)
}
@@ -100,7 +98,6 @@ func main() {
continue
}
out, err := os.Create(path.Join(destination, strings.TrimSuffix(filepath.Base(hdr.Name), ".txt")))
-
if err != nil {
log.Fatalf("Failed to create new file. %s", err)
}
diff --git a/build/gocovmerge.go b/build/gocovmerge.go
index 6a1af5b58f..1d2652129f 100644
--- a/build/gocovmerge.go
+++ b/build/gocovmerge.go
@@ -22,7 +22,7 @@ import (
"golang.org/x/tools/cover"
)
-func mergeProfiles(p *cover.Profile, merge *cover.Profile) {
+func mergeProfiles(p, merge *cover.Profile) {
if p.Mode != merge.Mode {
log.Fatalf("cannot merge profiles with different modes")
}