Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noamt/goptr
Pointer utilities for go
https://github.com/noamt/goptr
go golang pointer pointers ptr util utility
Last synced: 16 days ago
JSON representation
Pointer utilities for go
- Host: GitHub
- URL: https://github.com/noamt/goptr
- Owner: noamt
- License: apache-2.0
- Created: 2020-02-10T16:11:48.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-11T11:09:24.000Z (almost 5 years ago)
- Last Synced: 2024-06-20T11:51:32.625Z (6 months ago)
- Topics: go, golang, pointer, pointers, ptr, util, utility
- Language: Go
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.asciidoc
- License: LICENSE
Awesome Lists containing this project
README
= goptr
image:https://circleci.com/gh/noamt/goptr.svg?style=svg["CircleCI", link="https://circleci.com/gh/noamt/goptr"]
A utility package for Go pointers
== Pointer Resolution
In this package there are helper methods for resolving pointers of primitive types, with a fallback to a default value.
For example, resolving a pointer to a string:
[source,go]
----
import "github.com/noamt/goptr"goptr.String(nil) // Returns an empty string
goptr.String("foo") // Returns "foo"goptr.StringOrDefault(nil, "foo") // Returns "foo"
s := "bar"
goptr.StringOrDefault(&s, "foo") // Returns "bar"
----