Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSGK committed Jan 12, 2024
1 parent 8bdf00a commit 739015b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion cmd/lekko/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@ func configGroup() *cobra.Command {
}
defer pf.Close()
// Write proto file preamble
pf.WriteString(fmt.Sprintf("syntax = \"proto3\";\n\npackage %s;\n\n", protoPkg))
if _, err := pf.WriteString(fmt.Sprintf("syntax = \"proto3\";\n\npackage %s;\n\n", protoPkg)); err != nil {
return errors.Wrap(err, "write preamble to destination proto file")
}
}
pf, err := os.OpenFile(protoPath, os.O_APPEND|os.O_WRONLY, 0644)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions pkg/feature/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,17 +907,17 @@ func SuggestGroupedNames(configs ...*Feature) []string {

// Builder for a protobuf message definition string
type ProtoDefBuilder struct {
sb *strings.Builder
curFieldId int
done bool
sb *strings.Builder
curFieldNumber int
done bool
}

func NewProtoDefBuilder(name string) *ProtoDefBuilder {
sb := &strings.Builder{}
sb.WriteString(fmt.Sprintf("message %s {\n", name))
return &ProtoDefBuilder{
sb: sb,
curFieldId: 1,
sb: sb,
curFieldNumber: 1,
}
}

Expand Down Expand Up @@ -947,8 +947,8 @@ func (b *ProtoDefBuilder) AddField(name string, typeName string, comment string)
b.sb.WriteString(fmt.Sprintf("// %s\n", cl))
}
ffn := b.formatFieldName(name)
b.sb.WriteString(fmt.Sprintf("%s %s = %d;\n", typeName, ffn, b.curFieldId))
b.curFieldId++
b.sb.WriteString(fmt.Sprintf("%s %s = %d;\n", typeName, ffn, b.curFieldNumber))
b.curFieldNumber++
return ffn
}

Expand Down

0 comments on commit 739015b

Please sign in to comment.