Skip to content

Commit

Permalink
feat: Utility function: Ref and Deref (#42)
Browse files Browse the repository at this point in the history
* feat: Utility function: Ref and Deref

* chore: Bump reviewdog/action-golangci-lint to v2
  • Loading branch information
sawadashota authored May 12, 2022
1 parent b5f0d43 commit cd34ba9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 33 deletions.
33 changes: 2 additions & 31 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,12 @@ name: Lint
jobs:
golangci:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.16' ]
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}

- uses: actions/cache@v2
with:
path: ~/.cache/golangci-lint
key: ${{ runner.os }}-golangcilint-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golangci-lint-
- uses: actions/cache@v2
with:
path: ~/.cache/go-build
key: ${{ runner.os }}-gobuild-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gobuild-
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
uses: actions/checkout@v3

- name: golangci-lint
uses: reviewdog/action-golangci-lint@v1
uses: reviewdog/action-golangci-lint@v2
with:
reporter: github-pr-review
filter_mode: diff_context
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.16' ]
go: [ '1.18' ]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tier4/x-go

go 1.17
go 1.18

require (
github.com/aws/aws-sdk-go v1.43.8
Expand Down
13 changes: 13 additions & 0 deletions ref/ref.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ref

func Ref[T any](s T) *T {
return &s
}

func Deref[T any](p *T) T {
if p == nil {
var ret T
return ret
}
return *p
}

0 comments on commit cd34ba9

Please sign in to comment.