Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#9 Add Go 1.18 with generics #10

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name: Go

on: [ push, workflow_dispatch ]
on: [push, workflow_dispatch]

jobs:
golangcilint:
name: Golangci Lint
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: v1.41
version: v1.51
test:
strategy:
matrix:
go-version: [ 1.16.x ]
name: Tests
go-version: [1.18.x, 1.19.x, 1.20.x]
name: Unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Go install
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Run tests
Expand Down
102 changes: 54 additions & 48 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,46 @@
run:
modules-download-mode: readonly # Do not update dependencies.

linters-settings:
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
lll:
line-length: 160
maligned:
suggest-new: true
misspell:
locale: US
staticcheck:
go: "1.16"
gosimple:
go: "1.16"
stylecheck:
go: "1.16"
unused:
go: "1.16"

varnamelen:
min-name-length: 2
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
# Default linters
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
# Additional linters
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- cyclop
- decorder
- depguard
- dogsled
- dupl
- dupword
- durationcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
# - exhaustivestruct
- exhaustruct
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gci
# - ginkgolinter # Will be enabled in 1.51.
# - gocheckcompilerdirectives # Will be enabled in 1.51.
- gochecknoglobals
- gochecknoinits
- gocognit
Expand All @@ -78,47 +52,79 @@ linters:
- goerr113
- gofmt
- gofumpt
- goheader # Configure it
- goheader
- goimports
- gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- grouper
- importas
- interfacebloat
# - ireturn # Does not support generics, see https://github.com/butuzov/ireturn/issues/39.
- lll
- loggercheck
- maintidx
- makezero
- misspell
# - musttag # Will be enabled in 1.51.
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
# - nolintlint # Let's keed nolintlint if we decide to add it.
# - nonamedreturns # This linter does not make any sense.
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- sqlclosecheck
- stylecheck
- tagliatelle
- tenv
- testableexamples
- testpackage
- thelper
- tparallel
- unconvert
- unparam
- usestdlibvars
- varnamelen
- wastedassign
- whitespace
- wrapcheck
- wsl

issues:
exclude-rules:
- path: _test\.go
linters:
- gocyclo
- funlen
- goerr113
- dupl
- exhaustivestruct
- dupl
- funlen
- dupword
- path: doc\.go
linters:
- lll
- path: constraints\/constraints_test\.go
linters:
- gocritic
- wsl
- gochecknoglobals
- varnamelen
- gosec
- cyclop
- unconvert
- paralleltest
- tparallel
- unused

# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
golangci-lint-version: 1.51.x # use the fixed version to not introduce new linters unexpectedly
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
[![Codecov](https://codecov.io/gh/aohorodnyk/binflags/branch/main/graph/badge.svg?token=61SCDABJJ0)](https://codecov.io/gh/aohorodnyk/binflags) ![Test](https://github.com/aohorodnyk/binflags/workflows/Test/badge.svg) ![Lint](https://github.com/aohorodnyk/binflags/workflows/Lint/badge.svg)

## Golang 1.18
If you use Golang version 1.18 and above, I'll suggest to use [binflags](https://pkg.go.dev/github.com/aohorodnyk/stl/collections/binflags) package from [STL](https://pkg.go.dev/github.com/aohorodnyk/stl) library.

The package was built to use Go 1.18 with generics. If you need older version, see please the version [v0.0.3](https://github.com/aohorodnyk/binflags/releases/tag/v0.0.3).

## Motivation
There are number of needs to implement bitset for various types, and some "Big Flags" implementation through map or array of INTs.
Expand All @@ -36,7 +37,7 @@ There are known limitations:
### Examples in unit tests
Full list of examples can be found in `*_test.go` files. This library has coverage ~100%, and I'm gonna keep the level.

### Check has flag in base types
### Check has flag in base types
```go
package main

Expand Down
34 changes: 0 additions & 34 deletions array_int16.go

This file was deleted.

Loading