Compare commits
2 Commits
779818e067
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 21017ea5b8 | |||
|
|
05ed4eb281 |
26
.gitea/workflows/goaction.yml
Normal file
26
.gitea/workflows/goaction.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
name: Go Action
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
goaction:
|
||||
runs-on: ubuntu-latest # Use a Gitea Actions runner label
|
||||
steps:
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4 # Action to clone the repo
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5 # Action to install a specific Go version
|
||||
with:
|
||||
go-version: '1.25.5' # Specify your required Go version
|
||||
|
||||
- name: Run golangci-lint
|
||||
uses: golangci/golangci-lint-action@v8 # Use the golangci-lint action
|
||||
with:
|
||||
version: v2.7.2 # Specify the linter version
|
||||
# Optional: additional arguments
|
||||
args: --verbose
|
||||
|
||||
- name: Run go test
|
||||
run: go test ./...
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
linters-settings:
|
||||
version: "2"
|
||||
linters:
|
||||
default: all
|
||||
disable:
|
||||
- wsl
|
||||
- recvcheck
|
||||
- gochecknoglobals
|
||||
- ireturn
|
||||
- mnd
|
||||
- nolintlint
|
||||
settings:
|
||||
dupl:
|
||||
threshold: 100
|
||||
funlen:
|
||||
@@ -9,12 +19,8 @@ linters-settings:
|
||||
min-occurrences: 2
|
||||
gocyclo:
|
||||
min-complexity: 15
|
||||
golint:
|
||||
min-confidence: 0
|
||||
lll:
|
||||
line-length: 140
|
||||
maligned:
|
||||
suggest-new: true
|
||||
misspell:
|
||||
locale: US
|
||||
varnamelen:
|
||||
@@ -26,25 +32,33 @@ linters-settings:
|
||||
- i int
|
||||
- b bytes.Buffer
|
||||
- h Handle
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- gochecknoglobals
|
||||
- ireturn
|
||||
- mnd
|
||||
- nolintlint
|
||||
# deprecated
|
||||
- gomnd
|
||||
- exportloopref
|
||||
- execinquery
|
||||
|
||||
issues:
|
||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
||||
exclude-rules:
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- gochecknoglobals
|
||||
- depguard
|
||||
- gosec
|
||||
- errchkjson
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
rules:
|
||||
- linters:
|
||||
- depguard
|
||||
- errchkjson
|
||||
- gochecknoglobals
|
||||
- gosec
|
||||
path: _test\.go
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
formatters:
|
||||
enable:
|
||||
- gci
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- goimports
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
# bytesize
|
||||
|
||||

|
||||
[](https://goreportcard.com/report/gitoa.ru/go-4devs/bytesize)
|
||||
[](http://godoc.org/gitoa.ru/go-4devs/bytesize)
|
||||
|
||||
|
||||
3
size.go
3
size.go
@@ -86,7 +86,7 @@ func Parse(in string) (Size, error) {
|
||||
var err error
|
||||
|
||||
// The next character must be [0-9.]
|
||||
if !(in[0] == '.' || '0' <= in[0] && in[0] <= '9') {
|
||||
if in[0] != '.' && ('0' > in[0] || in[0] > '9') {
|
||||
return 0, fmt.Errorf("%w %q", ErrInvalidSize, orig)
|
||||
}
|
||||
|
||||
@@ -245,6 +245,7 @@ func leadingInt[bytes []byte | string](in bytes) (uint64, bytes, error) {
|
||||
|
||||
func (s Size) String() string {
|
||||
var arr [32]byte
|
||||
|
||||
n := s.format(&arr)
|
||||
|
||||
return string(arr[n:])
|
||||
|
||||
@@ -44,8 +44,8 @@ func TestUnmarshalText(t *testing.T) {
|
||||
|
||||
for _, tc := range marshalTextTests {
|
||||
var data bytesize.Size
|
||||
err := json.Unmarshal([]byte(tc.expect), &data)
|
||||
|
||||
err := json.Unmarshal([]byte(tc.expect), &data)
|
||||
if err != nil {
|
||||
t.Errorf("json.Unmarshal(%q) = _, err:%q", tc.in, err)
|
||||
} else if data != tc.in {
|
||||
|
||||
Reference in New Issue
Block a user