-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from lets-cli/upgrade-to-go-1.18
go1.18
- Loading branch information
Showing
16 changed files
with
91 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ on: | |
|
||
name: Test | ||
jobs: | ||
test: | ||
test-unit: | ||
strategy: | ||
matrix: | ||
platform: [ubuntu-latest, macos-latest] | ||
|
@@ -20,39 +20,36 @@ jobs: | |
if: runner.os == 'macOS' | ||
run: brew install bash | ||
- name: Setup go | ||
uses: actions/setup-go@v1 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.x | ||
go-version: 1.18.x | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Test unit | ||
env: | ||
LETS_CONFIG_DIR: .. | ||
run: go test ./... -v | ||
|
||
test-bats: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Install Lets | ||
uses: lets-cli/[email protected] | ||
with: | ||
version: latest | ||
- name: Test bats | ||
env: | ||
NO_COLOR: 1 | ||
run: | | ||
git clone git://github.com/bats-core/bats-core | ||
git clone git://github.com/bats-core/bats-support.git bats-core/bats-support | ||
git clone git://github.com/bats-core/bats-assert.git bats-core/bats-assert | ||
cd bats-core | ||
./install.sh ../ | ||
cd ../ | ||
PATH=${PATH}:$(pwd) | ||
go build -o lets *.go | ||
BATS_UTILS_PATH=./bats-core ./bin/bats tests | ||
run: lets test-bats | ||
|
||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.17.x | ||
- name: Checkout code | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Lint | ||
run: | | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.37.0 | ||
./bin/golangci-lint run -v -c .golangci.yaml | ||
- name: Install Lets | ||
uses: lets-cli/[email protected] | ||
with: | ||
version: latest | ||
- name: Run lint | ||
run: lets lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
FROM golangci/golangci-lint:v1.37-alpine | ||
FROM golangci/golangci-lint:v1.45-alpine | ||
|
||
RUN mkdir -p /.cache && chmod -R 777 /.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,35 @@ | ||
package set | ||
|
||
type StringSet struct { | ||
entryMap map[string]struct{} | ||
} | ||
|
||
func (s *StringSet) Add(value string) { | ||
s.entryMap[value] = struct{}{} | ||
} | ||
type Set[T comparable] map[T]struct{} | ||
|
||
func (s *StringSet) AddMany(values []string) { | ||
func (s Set[T]) Add(values ...T) { | ||
for _, value := range values { | ||
s.entryMap[value] = struct{}{} | ||
s[value] = struct{}{} | ||
} | ||
} | ||
|
||
func (s *StringSet) ToList() []string { | ||
values := make([]string, 0, len(s.entryMap)) | ||
for k := range s.entryMap { | ||
func (s Set[T]) ToList() []T { | ||
values := make([]T, 0, len(s)) | ||
for k := range s { | ||
values = append(values, k) | ||
} | ||
|
||
return values | ||
} | ||
|
||
func (s *StringSet) Remove(value string) { | ||
delete(s.entryMap, value) | ||
func (s Set[T]) Remove(value T) { | ||
delete(s, value) | ||
} | ||
|
||
func (s *StringSet) Contains(value string) bool { | ||
_, c := s.entryMap[value] | ||
func (s Set[T]) Contains(value T) bool { | ||
_, c := s[value] | ||
|
||
return c | ||
} | ||
|
||
func NewStringSet() *StringSet { | ||
return &StringSet{ | ||
entryMap: make(map[string]struct{}), | ||
} | ||
} | ||
|
||
func NewStringSetWithValues(values []string) *StringSet { | ||
set := &StringSet{ | ||
entryMap: make(map[string]struct{}), | ||
} | ||
set.AddMany(values) | ||
func NewSet[T comparable](values ...T) Set[T] { | ||
set := make(Set[T]) | ||
set.Add(values...) | ||
|
||
return set | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.