add workflow
All checks were successful
Go Action / goaction (push) Successful in 1m3s
Go Action / goaction (pull_request) Successful in 41s

This commit is contained in:
andrey
2025-12-24 00:12:33 +03:00
parent 779818e067
commit 05ed4eb281
5 changed files with 75 additions and 30 deletions

View 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 ./...

View File

@@ -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,14 +19,10 @@ 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:
min-name-length: 2 min-name-length: 2
ignore-decls: ignore-decls:
@@ -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$

View File

@@ -1,2 +1,6 @@
# bytesize # bytesize
![Build Status](https://gitoa.ru/go-4devs/bytesize/actions/workflows/goaction.yml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/gitoa.ru/go-4devs/bytesize)](https://goreportcard.com/report/gitoa.ru/go-4devs/bytesize)
[![GoDoc](https://godoc.org/gitoa.ru/go-4devs/bytesize?status.svg)](http://godoc.org/gitoa.ru/go-4devs/bytesize)

View File

@@ -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:])

View File

@@ -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 {