-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Utility function: Ref and Deref (#42)
* feat: Utility function: Ref and Deref * chore: Bump reviewdog/action-golangci-lint to v2
- Loading branch information
1 parent
b5f0d43
commit cd34ba9
Showing
4 changed files
with
17 additions
and
33 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
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,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 | ||
|
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 |
---|---|---|
@@ -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 | ||
} |