You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using this package, I found that the return type of the Parse method didn't give me access to any of the attributes on the ConventionalCommit object.
Minimal Reproducer
package main
import (
"fmt"
"github.com/leodido/go-conventionalcommits"
"github.com/leodido/go-conventionalcommits/parser"
)
// Example from https://github.com/leodido/go-conventionalcommits/blob/2713df998a1596207af6090215be9cbe2fd651be/parser/example_test.go#L81
func main() {
i := []byte(`fix: correct minor typos in code
see the issue [0] for details
on typos fixed.
[0]: https://issue
Reviewed-by: Z
Refs #133`)
opts := []conventionalcommits.MachineOption{
parser.WithTypes(conventionalcommits.TypesConventional),
}
m, _ := parser.NewMachine(opts...).Parse(i)
// fmt.Printf("%+v", m)
fmt.Println(m.Description)
}
When running with the code above, I get:
./main.go:27:16: m.Description undefined (type conventionalcommits.Message has no field or method Description)
If you comment out the line referencing the Description and dump the object you get:
&{Type:fix Description:correct minor typos in code Scope:<nil> Exclamation:false Body:0x140001181b8 Footers:map[refs:[133] reviewed-by:[Z]] TypeConfig:1}⏎
I think the fix for this is changing the return types to be the more specific *conventionalcommits.ConventionalCommit. This shouldn't lose any functionality because the ConventionalCommit struct implements the Message interface (it took me a quick reference to how interfaces work to figure this out)
The text was updated successfully, but these errors were encountered:
When using this package, I found that the return type of the Parse method didn't give me access to any of the attributes on the ConventionalCommit object.
Minimal Reproducer
When running with the code above, I get:
If you comment out the line referencing the Description and dump the object you get:
I think this is because the
Parse
method returns a Message object instead of a ConventionalCommitEven though the attributes get specified in the object, the type system isn't aware that those properties are available.
I think the fix for this is changing the return types to be the more specific
*conventionalcommits.ConventionalCommit
. This shouldn't lose any functionality because the ConventionalCommit struct implements the Message interface (it took me a quick reference to how interfaces work to figure this out)The text was updated successfully, but these errors were encountered: