Skip to content

Commit

Permalink
feat: add gci.yml and improve golangci.yml
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
houseme committed Dec 5, 2024
1 parent 4ad061f commit 523912b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/gci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
#
# This Source Code Form is subject to the terms of the MIT License.
# If a copy of the MIT was not distributed with this file,
# You can obtain one at /~https://github.com/gogf/gf.

# format go imports

name: Format Go Imports

on: [push, pull_request]

jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '^1.23.4' # set the go version as needed
- name: Install gci
run: go install github.com/daixiang0/gci@latest
- name: Run gci
run: gci write ./...
7 changes: 6 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ linters:
- goconst # Finds repeated strings that could be replaced by a constant
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
- goimports # Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode.
- gosimple # Linter for Go source code that specializes in simplifying code
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
- misspell # Finds commonly misspelled English words in comments
Expand Down Expand Up @@ -79,7 +80,11 @@ linters-settings:
locale: US
ignore-words:
- cancelled

goimports:
# A comma-separated list of prefixes, which, if set, checks import paths
# with the given prefixes are grouped after 3rd-party packages.
# Default: ""
local-prefixes: github.com/gogf/gf/v2
# https://golangci-lint.run/usage/linters/#revive
# /~https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
revive:
Expand Down
1 change: 1 addition & 0 deletions container/gtree/gtree_avltree.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"

"github.com/emirpasic/gods/trees/avltree"

"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/internal/rwmutex"
"github.com/gogf/gf/v2/text/gstr"
Expand Down
1 change: 1 addition & 0 deletions container/gtree/gtree_btree.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"

"github.com/emirpasic/gods/trees/btree"

"github.com/gogf/gf/v2/container/gvar"
"github.com/gogf/gf/v2/internal/rwmutex"
"github.com/gogf/gf/v2/text/gstr"
Expand Down
3 changes: 2 additions & 1 deletion encoding/ghtml/ghtml.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
"reflect"
"strings"

strip "github.com/grokify/html-strip-tags-go"

"github.com/gogf/gf/v2/errors/gcode"
"github.com/gogf/gf/v2/errors/gerror"
strip "github.com/grokify/html-strip-tags-go"
)

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

0 comments on commit 523912b

Please sign in to comment.