MCPcopy Create free account
hub / github.com/go-task/task / parsePlatform

Method parsePlatform

taskfile/ast/platforms.go:56–70  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
56func (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

Callers 2

UnmarshalYAMLMethod · 0.95
TestPlatformParsingFunction · 0.95

Calls 2

parseOsOrArchMethod · 0.95
parseArchMethod · 0.95

Tested by 1

TestPlatformParsingFunction · 0.76