GoLobby Cast is a lightweight casting package for Go projects.
It requires Go v1.16
or newer versions.
To install this package, run the following command in your project directory.
go get github.com/golobby/cast
The following examples demonstrate how to use the GoLobby Cast package.
val, err := cast.FromString("666", "int32")
// `val` type: int32
// `val` value: 666
val, err := cast.FromString("1", cast.Bool)
// `val` type: bool
// `val` value: true
Currently, the GoLobby Cast supports the following types and related array types:
- Int (Int8 .. Int64)
- Uint (Uint8 .. Uint64)
- Float32 and Float64
- Bool
- String
GoLobby Cast is released under the MIT License.