https://github.com/initdc/types
Bring the Rust [Result Option] types to Golang
https://github.com/initdc/types
error-handling go option-type result-type rust
Last synced: 14 days ago
JSON representation
Bring the Rust [Result Option] types to Golang
- Host: GitHub
- URL: https://github.com/initdc/types
- Owner: initdc
- License: mpl-2.0
- Created: 2025-11-24T12:05:08.000Z (7 months ago)
- Default Branch: dev
- Last Pushed: 2026-05-29T03:29:22.000Z (15 days ago)
- Last Synced: 2026-05-29T05:17:29.854Z (15 days ago)
- Topics: error-handling, go, option-type, result-type, rust
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# types
Bring the Rust [Result Option] types to Golang
## Installation
`go get github.com/initdc/types@dev`
## Usage
```go
package e2e_test
import (
"fmt"
. "github.com/initdc/types/option"
. "github.com/initdc/types/result"
"testing"
)
func TestE2E(t *testing.T) {
// Option
s1 := Some(1)
var s2 Option[int]
s2.None()
n1 := None[int]()
// Result
var r1 Result[int, string]
r1.Ok(1)
var e1 Result[int, string]
e1.Err("error")
r2 := Ok[int, string](1)
e2 := Err[int, string]("error")
fmt.Printf("%#v\n", s1)
fmt.Printf("%#v\n", s2)
fmt.Printf("%#v\n", n1)
fmt.Printf("%#v\n", r1)
fmt.Printf("%#v\n", e1)
fmt.Printf("%#v\n", r2)
fmt.Printf("%#v\n", e2)
}
```
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/initdc/types.