Skip to content

Commit 6c7603b

Browse files
committed
Small refactoring, no code change
1 parent 0c28634 commit 6c7603b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

internal/arduino/sketch/profiles.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ type ProfileLibraryReference struct {
358358
// UnmarshalYAML decodes a ProfileLibraryReference from YAML source.
359359
func (l *ProfileLibraryReference) UnmarshalYAML(unmarshal func(interface{}) error) error {
360360
var dataMap map[string]any
361+
var data string
361362
if err := unmarshal(&dataMap); err == nil {
362363
if installDir, ok := dataMap["dir"]; ok {
363364
if installDir, ok := installDir.(string); !ok {
@@ -367,8 +368,7 @@ func (l *ProfileLibraryReference) UnmarshalYAML(unmarshal func(interface{}) erro
367368
l.Library = l.InstallDir.Base()
368369
return nil
369370
}
370-
}
371-
if gitUrl, ok := dataMap["git"]; ok {
371+
} else if gitUrl, ok := dataMap["git"]; ok {
372372
if gitUrlStr, ok := gitUrl.(string); !ok {
373373
return fmt.Errorf("%s: %s", i18n.Tr("invalid git library reference: %s"), dataMap)
374374
} else if parsedUrl, err := url.Parse(gitUrlStr); err != nil {
@@ -381,14 +381,13 @@ func (l *ProfileLibraryReference) UnmarshalYAML(unmarshal func(interface{}) erro
381381
l.Library = strings.TrimSuffix(l.Library, ".git")
382382
return nil
383383
}
384+
} else {
385+
return errors.New(i18n.Tr("invalid library reference: %s", dataMap))
384386
}
385-
return errors.New(i18n.Tr("invalid library reference: %s", dataMap))
386-
}
387-
388-
var data string
389-
if err := unmarshal(&data); err != nil {
387+
} else if err := unmarshal(&data); err != nil {
390388
return err
391389
}
390+
392391
if libName, libVersion, ok := parseNameAndVersion(data); !ok {
393392
return fmt.Errorf("%s %s", i18n.Tr("invalid library directive:"), data)
394393
} else if v, err := semver.Parse(libVersion); err != nil {

0 commit comments

Comments
 (0)