Skip to content
/ ptr Public

Helper functions for working with Go pointers

License

Notifications You must be signed in to change notification settings

agrea/ptr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ptr

The ptr package gives you some basic helpers for working with pointers in Go. The package is simply intended to make it easy to create pointers to things. E.g. instead of writing:

s := "some string"
b := &s

You'd just write

b := ptr.String("some string")

Usage

ptr.Bool(true)        // Returns *bool
ptr.Byte(byte('a'))   // Returns *byte
ptr.Float32(123.3)    // Returns *float32
ptr.Float64(123.3)    // Returns *float64
ptr.Int(123)          // Returns *int
ptr.Int8(123)         // Returns *int8
ptr.Int16(123)        // Returns *int16
ptr.Int32(123)        // Returns *int32
ptr.Int64(123)        // Returns *int64
ptr.Rune(123)         // Returns *rune
ptr.String("string")  // Returns *string
ptr.Time(time.Now())  // Returns *time.Time
ptr.Uint(123)         // Returns *uint
ptr.Uint8(123)        // Returns *uint8
ptr.Uint16(123)       // Returns *uint16
ptr.Uint32(123)       // Returns *uint32
ptr.Uint64(123)       // Returns *uint64

Running the tests

go test -v ./...

License

MIT

About

Helper functions for working with Go pointers

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages