Skip to content

Commit

Permalink
Merge pull request #2 from adamweixuan/dev
Browse files Browse the repository at this point in the history
release
  • Loading branch information
0x1042 committed May 8, 2023
2 parents 675df35 + c8ba51d commit d213ef5
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 12 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build

on:
push:
branches:
- 'master'
tags:
- 'v*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: "1.20"
cache: true
- run: go mod tidy
- run: go test -v ./...
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_PAT }}
- uses: goreleaser/goreleaser-action@v2
if: success() && startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.vscode
bin
log

dist/
74 changes: 74 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
before:
hooks:
- go mod tidy
- go generate ./...
- go vet ./...

builds:
- binary: lt
ldflags:
- -s -w
tags:
- netgo
env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
- freebsd

goarch:
- 386
- amd64
- arm
- arm64
- riscv64
- mips
- mipsle
- mips64
- mips64le

# goarm:
# - 6
# goamd64:
# - v2
gomips:
- hardfloat
- softfloat

ignore:
- goos: darwin
goarch: 386 riscv64
- goos: linux
goarch: arm
goarm: 7
- goarm: mips64
- gomips: hardfloat
- goos: windows
goarch: riscv64 mips mipsle mips64le mips64

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
File renamed without changes.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ go 1.20
require (
github.com/google/uuid v1.3.0
github.com/lmittmann/tint v0.3.2
github.com/urfave/cli/v2 v2.25.1
github.com/urfave/cli/v2 v2.25.3
golang.org/x/crypto v0.8.0
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/sys v0.8.0 // indirect
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ github.com/lmittmann/tint v0.3.2 h1:PU2S17rAGhz5mo5shxnybv6Vwz7E08/RlOeWrwabuyg=
github.com/lmittmann/tint v0.3.2/go.mod h1:w5kXnXdS9aMMlo2eFRTyEPrSRywqAi44wbSUxIBfd38=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/urfave/cli/v2 v2.25.3 h1:VJkt6wvEBOoSjPFQvOkv6iWIrsJyCrKGtCtxXWwmGeY=
github.com/urfave/cli/v2 v2.25.3/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb h1:rhjz/8Mbfa8xROFiH+MQphmAmgqRM0bOMnytznhWEXk=
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53 h1:5llv2sWeaMSnA3w2kS57ouQQ4pudlXrR0dCgw51QK9o=
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
7 changes: 4 additions & 3 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ func (m *Map[K, V]) Load(key K) (value V, ok bool) {
}

func (m *Map[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
if v, ok := m.m.LoadAndDelete(key); ok {
return v.(V), loaded
v, ok := m.m.LoadAndDelete(key)
if !ok {
return value, loaded
}
return value, loaded
return v.(V), true
}

func (m *Map[K, V]) LoadOrStore(key K, value V) (V, bool) {
Expand Down

0 comments on commit d213ef5

Please sign in to comment.