Compare commits
2 Commits
779818e067
...
21017ea5b8
| 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:
|
dupl:
|
||||||
threshold: 100
|
threshold: 100
|
||||||
funlen:
|
funlen:
|
||||||
@@ -9,12 +19,8 @@ linters-settings:
|
|||||||
min-occurrences: 2
|
min-occurrences: 2
|
||||||
gocyclo:
|
gocyclo:
|
||||||
min-complexity: 15
|
min-complexity: 15
|
||||||
golint:
|
|
||||||
min-confidence: 0
|
|
||||||
lll:
|
lll:
|
||||||
line-length: 140
|
line-length: 140
|
||||||
maligned:
|
|
||||||
suggest-new: true
|
|
||||||
misspell:
|
misspell:
|
||||||
locale: US
|
locale: US
|
||||||
varnamelen:
|
varnamelen:
|
||||||
@@ -26,25 +32,33 @@ linters-settings:
|
|||||||
- i int
|
- i int
|
||||||
- b bytes.Buffer
|
- b bytes.Buffer
|
||||||
- h Handle
|
- h Handle
|
||||||
|
exclusions:
|
||||||
linters:
|
generated: lax
|
||||||
enable-all: true
|
presets:
|
||||||
disable:
|
- comments
|
||||||
- gochecknoglobals
|
- common-false-positives
|
||||||
- ireturn
|
- legacy
|
||||||
- mnd
|
- std-error-handling
|
||||||
- nolintlint
|
rules:
|
||||||
# deprecated
|
- linters:
|
||||||
- gomnd
|
- depguard
|
||||||
- exportloopref
|
- errchkjson
|
||||||
- execinquery
|
- gochecknoglobals
|
||||||
|
- gosec
|
||||||
issues:
|
path: _test\.go
|
||||||
# Excluding configuration per-path, per-linter, per-text and per-source
|
paths:
|
||||||
exclude-rules:
|
- third_party$
|
||||||
- path: _test\.go
|
- builtin$
|
||||||
linters:
|
- examples$
|
||||||
- gochecknoglobals
|
formatters:
|
||||||
- depguard
|
enable:
|
||||||
- gosec
|
- gci
|
||||||
- errchkjson
|
- gofmt
|
||||||
|
- gofumpt
|
||||||
|
- goimports
|
||||||
|
exclusions:
|
||||||
|
generated: lax
|
||||||
|
paths:
|
||||||
|
- third_party$
|
||||||
|
- builtin$
|
||||||
|
- examples$
|
||||||
|
|||||||
@@ -1,2 +1,6 @@
|
|||||||
# bytesize
|
# 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
|
var err error
|
||||||
|
|
||||||
// The next character must be [0-9.]
|
// 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)
|
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 {
|
func (s Size) String() string {
|
||||||
var arr [32]byte
|
var arr [32]byte
|
||||||
|
|
||||||
n := s.format(&arr)
|
n := s.format(&arr)
|
||||||
|
|
||||||
return string(arr[n:])
|
return string(arr[n:])
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ func TestUnmarshalText(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range marshalTextTests {
|
for _, tc := range marshalTextTests {
|
||||||
var data bytesize.Size
|
var data bytesize.Size
|
||||||
err := json.Unmarshal([]byte(tc.expect), &data)
|
|
||||||
|
|
||||||
|
err := json.Unmarshal([]byte(tc.expect), &data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("json.Unmarshal(%q) = _, err:%q", tc.in, err)
|
t.Errorf("json.Unmarshal(%q) = _, err:%q", tc.in, err)
|
||||||
} else if data != tc.in {
|
} else if data != tc.in {
|
||||||
|
|||||||
Reference in New Issue
Block a user