Merge pull request #32 from Loyalsoldier/fix-return-copylock-value

Fix: return copylock value
This commit is contained in:
Richard Chen 2020-07-21 19:25:05 +08:00 committed by GitHub
commit fc9f6c95c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
main.go
View File

@ -100,10 +100,10 @@ func parseDomain(domain string, entry *Entry) error {
return errors.New("Invalid format: " + domain) return errors.New("Invalid format: " + domain)
} }
func parseAttribute(attr string) (router.Domain_Attribute, error) { func parseAttribute(attr string) (*router.Domain_Attribute, error) {
var attribute router.Domain_Attribute var attribute router.Domain_Attribute
if len(attr) == 0 || attr[0] != '@' { if len(attr) == 0 || attr[0] != '@' {
return attribute, errors.New("invalid attribute: " + attr) return &attribute, errors.New("invalid attribute: " + attr)
} }
attr = attr[0:] attr = attr[0:]
@ -115,11 +115,11 @@ func parseAttribute(attr string) (router.Domain_Attribute, error) {
attribute.Key = strings.ToLower(parts[0]) attribute.Key = strings.ToLower(parts[0])
intv, err := strconv.Atoi(parts[1]) intv, err := strconv.Atoi(parts[1])
if err != nil { if err != nil {
return attribute, errors.New("invalid attribute: " + attr + ": " + err.Error()) return &attribute, errors.New("invalid attribute: " + attr + ": " + err.Error())
} }
attribute.TypedValue = &router.Domain_Attribute_IntValue{IntValue: int64(intv)} attribute.TypedValue = &router.Domain_Attribute_IntValue{IntValue: int64(intv)}
} }
return attribute, nil return &attribute, nil
} }
func parseEntry(line string) (Entry, error) { func parseEntry(line string) (Entry, error) {
@ -140,7 +140,7 @@ func parseEntry(line string) (Entry, error) {
if err != nil { if err != nil {
return entry, err return entry, err
} }
entry.Attrs = append(entry.Attrs, &attr) entry.Attrs = append(entry.Attrs, attr)
} }
return entry, nil return entry, nil