123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package sentio
- import (
- "fmt"
- "strings"
- )
- type Side int
- const (
- LONG Side = iota
- SHORT
- BASE
- )
- var sides = map[Side]string{
- LONG: "LONG",
- SHORT: "SHORT",
- BASE: "BASE",
- }
- func (s Side) String() string {
- side, ok := sides[s]
- if ok {
- return side
- }
- return "undefined"
- }
- func ParseSide(s string) (Side, error) {
- s = strings.TrimSpace(s)
- s = strings.ToUpper(s)
- for side, s2 := range sides {
- if s == s2 {
- return side, nil
- }
- }
- return -1, fmt.Errorf("`sentio.ParseSide`: undefined Side `%s`", s)
- }
|