parsePlatform takes a string representing an OS/Arch combination (or either on their own) and parses it into the Platform struct. It returns an error if the input string is invalid. Valid combinations for input: OS, Arch, OS/Arch
(input string)
| 54 | // and parses it into the Platform struct. It returns an error if the input string is invalid. |
| 55 | // Valid combinations for input: OS, Arch, OS/Arch |
| 56 | func (p *Platform) parsePlatform(input string) error { |
| 57 | splitValues := strings.Split(input, "/") |
| 58 | if len(splitValues) > 2 { |
| 59 | return &ErrInvalidPlatform{Platform: input} |
| 60 | } |
| 61 | if err := p.parseOsOrArch(splitValues[0]); err != nil { |
| 62 | return &ErrInvalidPlatform{Platform: input} |
| 63 | } |
| 64 | if len(splitValues) == 2 { |
| 65 | if err := p.parseArch(splitValues[1]); err != nil { |
| 66 | return &ErrInvalidPlatform{Platform: input} |
| 67 | } |
| 68 | } |
| 69 | return nil |
| 70 | } |
| 71 | |
| 72 | // parseOsOrArch will check if the given input is a valid OS or Arch value. |
| 73 | // If so, it will store it. If not, an error is returned |