Skip to content
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
Empty file modified .github/workflows/cloc.yml
100755 → 100644
Empty file.
25 changes: 3 additions & 22 deletions .github/workflows/golangci-lint.yml
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,9 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: stable
go-version: oldstable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v8.0.0
uses: golangci/golangci-lint-action@v9.2.0
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v2.4.0

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
version: v2.11.3
Empty file modified .github/workflows/gorelease.yml
100755 → 100644
Empty file.
Empty file modified .github/workflows/test-unit.yml
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ run:
linters:
default: all
disable:
- embeddedstructfieldcheck
- nilnil
- noinlineerr
- wsl_v5
- funcorder
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#GOLANGCI_LINT_VERSION := "v2.5.0" # Optional configuration to pinpoint golangci-lint version.
#GOLANGCI_LINT_VERSION := "v2.11.3" # Optional configuration to pinpoint golangci-lint version.

# The head of Makefile determines location of dev-go to include standard targets.
GO ?= go
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/bool64/shared
go 1.17

require (
github.com/bool64/dev v0.2.43
github.com/bool64/dev v0.2.45
github.com/stretchr/testify v1.4.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/bool64/dev v0.2.43 h1:yQ7qiZVef6WtCl2vDYU0Y+qSq+0aBrQzY8KXkklk9cQ=
github.com/bool64/dev v0.2.43/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/bool64/dev v0.2.45 h1:3nLKhAS/6Oklk3Mt2lHYSN/Cb4tdAD77KLwzeP+6eYE=
github.com/bool64/dev v0.2.45/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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=
Expand Down
11 changes: 11 additions & 0 deletions vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ func (v *Vars) Set(key string, val interface{}) {
}
}

// Delete removes variable by name.
//
// After Delete, Get reports the variable as not found, same as if it had
// never been set.
func (v *Vars) Delete(key string) {
v.mu.Lock()
defer v.mu.Unlock()

delete(v.vars, key)
}

// OnSet adds callback to invoke when variable is set.
//
// All callbacks are removed on Reset.
Expand Down
18 changes: 18 additions & 0 deletions vars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ func TestVars_GetAll(t *testing.T) {
assert.Equal(t, map[string]interface{}{}, v.GetAll())
}

func TestVars_Delete(t *testing.T) {
v := shared.Vars{}
v.Set("k", "v")
v.Set("other", "unaffected")

v.Delete("k")

val, found := v.Get("k")
assert.False(t, found)
assert.Nil(t, val)
assert.Equal(t, map[string]interface{}{"other": "unaffected"}, v.GetAll())

// Deleting an already-absent (or never-set) key is a no-op, not an error.
v.Delete("k")
v.Delete("never-set")
assert.Equal(t, map[string]interface{}{"other": "unaffected"}, v.GetAll())
}

func TestVars_Fork(t *testing.T) {
v := shared.Vars{}
v.Set("k", "v")
Expand Down
Loading