spf13 / cast

safe and easy casting from one type to another in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support cast defined type

atsushi-ishibashi opened this issue · comments

// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"

	"github.com/spf13/cast"
)

type Hoge = string
type Fuga string

func main() {
	h := Hoge("hoge")
	f := Fuga("fuga")
	fmt.Println(h, f)
	fmt.Println(cast.ToString(h), cast.ToString(f))
}

// output
hoge fuga
hoge