add workflow #1

Merged
andrey merged 1 commits from workflow into master 2025-12-24 00:14:57 +03:00
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:
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$

View File

@@ -1,2 +1,6 @@
# 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
// 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:])

View File

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