Skip to content

Commit 74b7c77

Browse files
committed
Initial commit
0 parents  commit 74b7c77

26 files changed

+1899
-0
lines changed

.github/workflows/go.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.18
20+
21+
- name: Build
22+
run: make build
23+
24+
- name: Test
25+
run: make test

.github/workflows/golangci-lint.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: golangci-lint
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
branches:
7+
- master
8+
- main
9+
pull_request:
10+
jobs:
11+
golangci:
12+
name: lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: golangci-lint
17+
uses: golangci/golangci-lint-action@v2
18+
with:
19+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
20+
version: latest
21+
22+
# Optional: working directory, useful for monorepos
23+
working-directory: ./
24+
25+
# Optional: golangci-lint command line arguments.
26+
args: --config=.golangci.yml --issues-exit-code=0 --timeout 60s --max-same-issues 50
27+
28+
# Optional: show only new issues if it's a pull request. The default value is `false`.
29+
# only-new-issues: true
30+
31+
# Optional: if set to true then the action will use pre-installed Go.
32+
# skip-go-installation: true
33+
34+
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
35+
# skip-pkg-cache: true
36+
37+
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
38+
# skip-build-cache: true

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/go
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=go
4+
5+
### Go ###
6+
# If you prefer the allow list template instead of the deny list, see community template:
7+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
8+
#
9+
# Binaries for programs and plugins
10+
*.exe
11+
*.exe~
12+
*.dll
13+
*.so
14+
*.dylib
15+
16+
# Test binary, built with `go test -c`
17+
*.test
18+
19+
# Output of the go coverage tool, specifically when used with LiteIDE
20+
*.out
21+
22+
# Dependency directories (remove the comment below to include it)
23+
# vendor/
24+
25+
# Go workspace file
26+
go.work
27+
28+
### Go Patch ###
29+
/vendor/
30+
/Godeps/
31+
32+
# End of https://www.toptal.com/developers/gitignore/api/go

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: go
2+
before_install:
3+
- go mod download
4+
- make tools
5+
go:
6+
- "1.18"
7+
script: make test

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"go.alternateTools": {
3+
"go": "/Users/samber/.go/bin/go1.18beta1"
4+
}
5+
}

CHANGELOG.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Changelog
2+
3+
## 1.0.0 (2022-03-02)
4+
5+
*Initial release*
6+
7+
Supported helpers for slices:
8+
9+
- Filter
10+
- Map
11+
- Reduce
12+
- ForEach
13+
- Uniq
14+
- UniqBy
15+
- GroupBy
16+
- Chunk
17+
- Flatten
18+
- Shuffle
19+
- Reverse
20+
- Fill
21+
- ToMap
22+
23+
Supported helpers for maps:
24+
25+
- Keys
26+
- Values
27+
- Entries
28+
- FromEntries
29+
- Assign (maps merge)
30+
31+
Supported intersection helpers:
32+
33+
- Contains
34+
- Every
35+
- Some
36+
- Intersect
37+
- Difference
38+
39+
Supported search helpers:
40+
41+
- IndexOf
42+
- LastIndexOf
43+
- Find
44+
- Min
45+
- Max
46+
- Last
47+
- Nth
48+
49+
Other functional programming helpers:
50+
51+
- Ternary (1 line if/else statement)
52+
- If / ElseIf / Else
53+
- Switch / Case / Default
54+
- ToPtr
55+
- ToSlicePtr
56+
57+
Constraints:
58+
59+
- Clonable
60+
- Ordered

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
FROM golang:1.18rc1-bullseye
3+
4+
WORKDIR /go/src/github.com/samber/lo
5+
6+
COPY Makefile go.* /go/src/github.com/samber/lo
7+
8+
RUN make tools

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Samuel Berthe
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
BIN=go
3+
# BIN=go1.18beta1
4+
5+
go1.18beta1:
6+
go install golang.org/dl/go1.18beta1@latest
7+
go1.18beta1 download
8+
9+
build:
10+
${BIN} build -v .
11+
12+
test:
13+
go test -v .
14+
watch-test: tools
15+
reflex -R assets.go -t 50ms -s -- sh -c 'gotest -v .'
16+
17+
bench:
18+
gotest -benchmem -bench .
19+
20+
# tools
21+
tools:
22+
${BIN} install github.com/cespare/reflex@latest
23+
${BIN} install github.com/rakyll/gotest@latest
24+
${BIN} install github.com/psampaz/go-mod-outdated@latest
25+
${BIN} install github.com/jondot/goweight@latest
26+
${BIN} install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
27+
${BIN} get -t -u github.com/sonatype-nexus-community/nancy@latest
28+
go mod tidy
29+
30+
lint:
31+
golangci-lint run --timeout 60s --max-same-issues 50 ./...
32+
lint-fix:
33+
golangci-lint run --timeout 60s --max-same-issues 50 --fix ./...
34+
35+
audit: tools
36+
${BIN} mod tidy
37+
${BIN} list -json -m all | nancy sleuth
38+
39+
outdated: tools
40+
${BIN} mod tidy
41+
${BIN} list -u -m -json all | go-mod-outdated -update -direct
42+
43+
weight: tools
44+
goweight

0 commit comments

Comments
 (0)