Skip to content

Commit 523912b

Browse files
committed
feat: add gci.yml and improve golangci.yml
1. Added `gci.yml` for GCI, a tool to control Go package import order and ensure determinism. 2. Improved `golangci.yml` by adding the `goimports` linter. 3. Optimized some import statements in the code.
1 parent 4ad061f commit 523912b

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

.github/workflows/gci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
2+
#
3+
# This Source Code Form is subject to the terms of the MIT License.
4+
# If a copy of the MIT was not distributed with this file,
5+
# You can obtain one at https://github.com/gogf/gf.
6+
7+
# format go imports
8+
9+
name: Format Go Imports
10+
11+
on: [push, pull_request]
12+
13+
jobs:
14+
format:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Go
19+
uses: actions/setup-go@v5
20+
with:
21+
go-version: '^1.23.4' # set the go version as needed
22+
- name: Install gci
23+
run: go install github.com/daixiang0/gci@latest
24+
- name: Run gci
25+
run: gci write ./...

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ linters:
4343
- goconst # Finds repeated strings that could be replaced by a constant
4444
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
4545
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
46+
- goimports # Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode.
4647
- gosimple # Linter for Go source code that specializes in simplifying code
4748
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
4849
- misspell # Finds commonly misspelled English words in comments
@@ -79,7 +80,11 @@ linters-settings:
7980
locale: US
8081
ignore-words:
8182
- cancelled
82-
83+
goimports:
84+
# A comma-separated list of prefixes, which, if set, checks import paths
85+
# with the given prefixes are grouped after 3rd-party packages.
86+
# Default: ""
87+
local-prefixes: github.com/gogf/gf/v2
8388
# https://golangci-lint.run/usage/linters/#revive
8489
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
8590
revive:

container/gtree/gtree_avltree.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111

1212
"github.com/emirpasic/gods/trees/avltree"
13+
1314
"github.com/gogf/gf/v2/container/gvar"
1415
"github.com/gogf/gf/v2/internal/rwmutex"
1516
"github.com/gogf/gf/v2/text/gstr"

container/gtree/gtree_btree.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"fmt"
1111

1212
"github.com/emirpasic/gods/trees/btree"
13+
1314
"github.com/gogf/gf/v2/container/gvar"
1415
"github.com/gogf/gf/v2/internal/rwmutex"
1516
"github.com/gogf/gf/v2/text/gstr"

encoding/ghtml/ghtml.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import (
1212
"reflect"
1313
"strings"
1414

15+
strip "github.com/grokify/html-strip-tags-go"
16+
1517
"github.com/gogf/gf/v2/errors/gcode"
1618
"github.com/gogf/gf/v2/errors/gerror"
17-
strip "github.com/grokify/html-strip-tags-go"
1819
)
1920

2021
// StripTags strips HTML tags from content, and returns only text.

0 commit comments

Comments
 (0)