User Tools

Site Tools


golang:ergonomics

Ergonomics

Источник

Use of a package like this may be pervasive if you really commit to it. This package was inspired by Rust's options implemenation. It might be worth considering dropping the repetative option. preceding the variants. Since importing names into the global namespace is to be avoided, the following import pattern may work for you:

import (
    "fmt"
 
    "github.com/BooleanCat/option"
)
 
var (
    Some = option.Some
    None = option.None
)
 
func main() {
    two := Some(2)
    fmt.Println(two)
}
golang/ergonomics.txt · Last modified: 2024/05/26 07:09 by Denis Evsyukov