Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cholland1989 committed Jun 30, 2024
0 parents commit ece7257
Show file tree
Hide file tree
Showing 15 changed files with 1,724 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build
on: [push]
jobs:
verify:
name: Verify dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Verify dependencies
run: make verify
check:
name: Run static analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
- name: Run static analysis
run: make check
test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run unit tests
run: make test
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# System

._*
.DS_Store
.Spotlight-V100
.Trashes
Thumbs.db

# Build

bin

# Compiled

*.class
*.com
*.dll
*.exe
*.o
*.so

# Archive

*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Miscellaneous

*.bak
*.log
*.sql
*.sqlite
*.swp
*.tmp

# Editor

.classpath
.idea
.project
.settings
.vscode
100 changes: 100 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- canonicalheader
- containedctx
- contextcheck
- cyclop
- decorder
- dogsled
- dupl
- dupword
- durationcheck
- err113
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exhaustruct
- exportloopref
- fatcontext
- forbidigo
- forcetypeassert
- funlen
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoinits
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- godox
- gofmt
- gofumpt
- goheader
- goimports
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- gosmopolitan
- govet
- grouper
- importas
- inamedparam
- ineffassign
- interfacebloat
- lll
- loggercheck
- maintidx
- makezero
- mirror
- misspell
- musttag
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- sloglint
- spancheck
- sqlclosecheck
- staticcheck
- stylecheck
- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
- thelper
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- varnamelen
- wastedassign
- whitespace
- zerologlint
run:
tests: false
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @cholland1989
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2024 Corey Holland

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
CGO_ENABLED?=0
GOAMD64?=v4

clean:
rm -rf bin/
go clean -cache -testcache

format:
go fmt ./...
go run mvdan.cc/gofumpt@latest -w .
go mod tidy

verify:
go mod verify
go run golang.org/x/vuln/cmd/govulncheck@latest ./...

check:
go vet ./...
go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run ./...
go run honnef.co/go/tools/cmd/staticcheck@latest -checks all ./...
go run go.uber.org/nilaway/cmd/nilaway@latest ./...
go run golang.org/x/tools/cmd/deadcode@latest -test ./...

test:
go test -vet off -count 1 -cover ./...

bench:
go test -vet off -run ^$$ -bench . -benchtime 30s -benchmem ./...

cover:
go test -vet off -cover -coverprofile cover.out ./...
go tool cover -html cover.out
rm -f cover.out

docs:
go run golang.org/x/tools/cmd/godoc@latest

build:
go build -o bin/ ./...
63 changes: 63 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# go-collection [![Documentation][doc-img]][doc] [![Build Status][ci-img]][ci]

Generic list, map, and set definitions with common utility methods.

## Installation

```bash
go get github.com/cholland1989/go-collection
```

This library supports [version 1.20 and later][ver] of Go.

## Usage

```go
import "github.com/cholland1989/go-collection/pkg/collection"
```

Lists can be used interchangeably with slices of the same type, and support
all of the same built-in functions such as `make`, `append`, and `range`:

```go
values := make(collection.List[int], 0)
values.AddAll(0, 1, 0, 1)
for index, value := range values {
fmt.Println(index, value)
}
```

Maps can be used interchangeably with maps of the same type, and support all
of the same built-in functions such as `make`, `delete`, and `range`:

```go
values := make(collection.Map[int, int])
values.Put(0, 1)
values.Put(1, 0)
for key, value := range values {
fmt.Println(key, value)
}
```

Sets can be used interchangeably with a map of empty structs, and support all
of the same built-in functions such as `make`, `delete`, and `range`:

```go
values := make(collection.Set[int])
values.AddAll(0, 1, 0, 1)
for value := range values {
fmt.Println(value)
}
```

See the [documentation][doc] for more details.

## License

Released under the [MIT License](LICENSE).

[ci]: https://github.com/cholland1989/go-collection/actions/workflows/build.yml
[ci-img]: https://github.com/cholland1989/go-collection/actions/workflows/build.yml/badge.svg
[doc]: https://pkg.go.dev/github.com/cholland1989/go-collection
[doc-img]: https://pkg.go.dev/badge/github.com/cholland1989/go-collection
[ver]: https://go.dev/doc/devel/release
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/cholland1989/go-collection

go 1.20

require github.com/stretchr/testify v1.9.0

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit ece7257

Please sign in to comment.