https://github.com/nicklaros/gopointer
Minimalist pointer utility for go.
https://github.com/nicklaros/gopointer
go pointer utility
Last synced: 3 months ago
JSON representation
Minimalist pointer utility for go.
- Host: GitHub
- URL: https://github.com/nicklaros/gopointer
- Owner: nicklaros
- License: mit
- Created: 2021-03-11T10:50:43.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-03-12T00:09:03.000Z (about 5 years ago)
- Last Synced: 2024-07-14T09:49:06.327Z (almost 2 years ago)
- Topics: go, pointer, utility
- Language: Go
- Homepage: https://pkg.go.dev/github.com/nicklaros/gopointer
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gopointer
Minimalistic pointer utility for go.
# Why Gopointer?
Gopointer makes golang easier by taking the hassle out of defining intermediary variable for
composite literal just so you can take it's address.

# How to use
Import package as follows
```
import "github.com/nicklaros/gopointer"
```
For boolean pointer
```
result := gopointer.BoolPointer(true) // result type is *bool.
```
For float32 pointer
```
result := gopointer.Float32Pointer(99.99) // result type is *float32.
```
For float64 pointer
```
result := gopointer.Float64Pointer(99.99) // result type is *float64.
```
For int pointer
```
result := gopointer.IntPointer(99) // result type is *int.
```
For int8 pointer
```
result := gopointer.Int8Pointer(99) // result type is *int8.
```
For int16 pointer
```
result := gopointer.Int16Pointer(99) // result type is *int16.
```
For int32 pointer
```
result := gopointer.Int32Pointer(99) // result type is *int32.
```
For int64 pointer
```
result := gopointer.Int64Pointer(99) // result type is *int64.
```
For string pointer
```
result := gopointer.StringPointer("Hi, you can store me in a pointer.") // result type is *string.
```
For time pointer
```
import "time"
result := gopointer.TimePointer(time.Now()) // result type is *time
```
For uint pointer
```
result := gopointer.UintPointer(99) // result type is *uint.
```
For uint8 pointer
```
result := gopointer.Uint8Pointer(99) // result type is *uint8.
```
For uint16 pointer
```
result := gopointer.Uint16Pointer(99) // result type is *uint16.
```
For uint32 pointer
```
result := gopointer.Uint32Pointer(99) // result type is *uint32.
```
For uint64 pointer
```
result := gopointer.Uint64Pointer(99) // result type is *uint64.
```