MCPcopy Index your code
hub / github.com/coder/coder / ParseRPCVersionList

Function ParseRPCVersionList

vpn/version.go:87–103  ·  view source on GitHub ↗

ParseRPCVersionList parses a version string in the format "major.minor,major.minor" into a RPCVersionList.

(str string)

Source from the content-addressed store, hash-verified

85// ParseRPCVersionList parses a version string in the format
86// "major.minor,major.minor" into a RPCVersionList.
87func ParseRPCVersionList(str string) (RPCVersionList, error) {
88 split := strings.Split(str, ",")
89 versions := make([]RPCVersion, len(split))
90 for i, v := range split {
91 version, err := ParseRPCVersion(v)
92 if err != nil {
93 return RPCVersionList{}, xerrors.Errorf("invalid version list: %s", str)
94 }
95 versions[i] = version
96 }
97 vl := RPCVersionList{Versions: versions}
98 err := vl.Validate()
99 if err != nil {
100 return RPCVersionList{}, xerrors.Errorf("invalid parsed version list %q: %w", str, err)
101 }
102 return vl, nil
103}
104
105func (vl RPCVersionList) String() string {
106 versionStrings := make([]string, len(vl.Versions))

Callers 2

validateHeaderFunction · 0.85

Calls 3

ValidateMethod · 0.95
ParseRPCVersionFunction · 0.85
ErrorfMethod · 0.45

Tested by 1