Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MD5 ¶
func MD5(v interface{}) string
MD5 is hashed with MD5.
Example ¶
package main import ( "fmt" "github.com/k-kinzal/aliases/pkg/types" ) func main() { var hasher types.Hasher = types.MD5 fmt.Println(hasher("abcde")) fmt.Println(hasher(struct{}{})) }
Output: ab56b4d92b40713acc5af89985d4b786 99914b932bd37a50b983c5e7c90ae93b
func SHA1 ¶
func SHA1(v interface{}) string
SHA1 is hashed with SHA1.
Example ¶
package main import ( "fmt" "github.com/k-kinzal/aliases/pkg/types" ) func main() { var hasher types.Hasher = types.SHA1 fmt.Println(hasher("abcde")) fmt.Println(hasher(struct{}{})) }
Output: 03de6c570bfe24bfc328ccd7ca46b76eadaf4334 bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f
func SHA256 ¶
func SHA256(v interface{}) string
SHA256 is hashed with SHA256.
Example ¶
package main import ( "fmt" "github.com/k-kinzal/aliases/pkg/types" ) func main() { var hasher types.Hasher = types.SHA256 fmt.Println(hasher("abcde")) fmt.Println(hasher(struct{}{})) }
Output: 36bbe50ed96841d10443bcb670d6554f0a34b761be67ec9c4a8ad2c0c44ca42c 44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set of data structure.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack is the FILO data structure.
func NewStack ¶
NewStack creates a new Stack.
Example ¶
stack := NewStack(nil) stack.Push(1) fmt.Println(stack.Pop())
Output: 1
func (*Stack) Pop ¶
func (stack *Stack) Pop() interface{}
Pop get data from first.
Example ¶
var hasher Hasher = MD5 stack := NewStack(hasher) stack.Push(1) stack.Push(2) fmt.Println(stack.Pop()) stack.Push(3) stack.Push(4) fmt.Println(stack.Pop(), stack.Pop(), stack.Pop(), stack.Pop())
Output: 2 4 3 1 <nil>
type Union ¶
type Union struct {
// contains filtered or unexported fields
}
Union has the value of type Left or Right.
func NewUnion ¶
NewUnion returns Union
Example ¶
package main import ( "fmt" "reflect" "github.com/k-kinzal/aliases/pkg/types" ) func main() { union1 := types.NewUnion(reflect.Int, reflect.String, 1) union2 := types.NewUnion(reflect.Int, reflect.String, "abc") fmt.Println(union1) fmt.Println(union2) }
Output: int(1) string("abc")
func (*Union) Left ¶
Left returns the type of Left.
Example ¶
package main import ( "fmt" "reflect" "github.com/k-kinzal/aliases/pkg/types" ) func main() { union := types.NewUnion(reflect.Int, reflect.String, "abc") fmt.Println(union.Left()) }
Output: int
func (*Union) Right ¶
Right returns the type of Right.
Example ¶
package main import ( "fmt" "reflect" "github.com/k-kinzal/aliases/pkg/types" ) func main() { union := types.NewUnion(reflect.Int, reflect.String, "abc") fmt.Println(union.Right()) }
Output: string
func (*Union) Type ¶
Type returns the type of Left or Right.
Example ¶
package main import ( "fmt" "reflect" "github.com/k-kinzal/aliases/pkg/types" ) func main() { union := types.NewUnion(reflect.Int, reflect.String, "abc") switch union.Type() { case union.Left(): fmt.Printf("Union is `%s`", union.Left()) case union.Right(): fmt.Printf("Union is `%s`", union.Right()) } }
Output: Union is `string`
func (*Union) Value ¶
func (u *Union) Value() interface{}
Value returns the value of type Left or Right. But you should extend the function returning the appropriate type without calling Value.
Example ¶
package main import ( "fmt" "reflect" "github.com/k-kinzal/aliases/pkg/types" ) func main() { union := types.NewUnion(reflect.Int, reflect.String, "abc") fmt.Println(union.Value()) }
Output: abc
Click to show internal directories.
Click to hide internal directories.