Skip to content

Commit

Permalink
Merge pull request #272 from octonawish-akcodes/fix
Browse files Browse the repository at this point in the history
typo fix in toml.go
  • Loading branch information
Peefy authored Feb 26, 2024
2 parents e0807e1 + c948c5d commit b197e0b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pkg/package/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,23 @@ func (source *Source) MarshalTOML() string {
return sb.String()
}

const GTI_URL_PATTERN = "git = \"%s\""
const GTI_TAG_PATTERN = "tag = \"%s\""
const GTI_COMMIT_PATTERN = "commit = \"%s\""
const GIT_URL_PATTERN = "git = \"%s\""
const GIT_TAG_PATTERN = "tag = \"%s\""
const GIT_COMMIT_PATTERN = "commit = \"%s\""
const SEPARATOR = ", "

func (git *Git) MarshalTOML() string {
var sb strings.Builder
if len(git.Url) != 0 {
sb.WriteString(fmt.Sprintf(GTI_URL_PATTERN, git.Url))
sb.WriteString(fmt.Sprintf(GIT_URL_PATTERN, git.Url))
}
if len(git.Tag) != 0 {
sb.WriteString(SEPARATOR)
sb.WriteString(fmt.Sprintf(GTI_TAG_PATTERN, git.Tag))
sb.WriteString(fmt.Sprintf(GIT_TAG_PATTERN, git.Tag))
}
if len(git.Commit) != 0 {
sb.WriteString(SEPARATOR)
sb.WriteString(fmt.Sprintf(GTI_COMMIT_PATTERN, git.Commit))
sb.WriteString(fmt.Sprintf(GIT_COMMIT_PATTERN, git.Commit))
}
return sb.String()
}
Expand Down Expand Up @@ -318,25 +318,25 @@ func (source *Source) UnmarshalModTOML(data interface{}) error {
return nil
}

const GTI_URL_FLAG = "git"
const GTI_TAG_FLAG = "tag"
const GTI_COMMIT_FLAG = "commit"
const GIT_URL_FLAG = "git"
const GIT_TAG_FLAG = "tag"
const GIT_COMMIT_FLAG = "commit"

func (git *Git) UnmarshalModTOML(data interface{}) error {
meta, ok := data.(map[string]interface{})
if !ok {
return fmt.Errorf("expected map[string]interface{}, got %T", data)
}

if v, ok := meta[GTI_URL_FLAG].(string); ok {
if v, ok := meta[GIT_URL_FLAG].(string); ok {
git.Url = v
}

if v, ok := meta[GTI_TAG_FLAG].(string); ok {
if v, ok := meta[GIT_TAG_FLAG].(string); ok {
git.Tag = v
}

if v, ok := meta[GTI_COMMIT_FLAG].(string); ok {
if v, ok := meta[GIT_COMMIT_FLAG].(string); ok {
git.Commit = v
}

Expand Down

0 comments on commit b197e0b

Please sign in to comment.