Skip to content

Commit

Permalink
Replaced merge-removed Parse function
Browse files Browse the repository at this point in the history
  • Loading branch information
dphilla committed Mar 5, 2024
1 parent 505ea13 commit 64dbccf
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@

package scale

import "strings"

type Parsed struct {
Organization string
Name string
Tag string
}

// Parse parses a function or signature name of the form <org>/<name>:<tag> into its organization, name, and tag
func Parse(name string) *Parsed {
orgSplit := strings.Split(name, "/")
if len(orgSplit) == 1 {
orgSplit = []string{"", name}
}
tagSplit := strings.Split(orgSplit[1], ":")
if len(tagSplit) == 1 {
tagSplit = []string{tagSplit[0], ""}
}
return &Parsed{
Organization: orgSplit[0],
Name: tagSplit[0],
Tag: tagSplit[1],
}
}

func unpackUint32(packed uint64) (uint32, uint32) {
return uint32(packed >> 32), uint32(packed)
}

0 comments on commit 64dbccf

Please sign in to comment.