Skip to content

Commit

Permalink
Address go vet errors
Browse files Browse the repository at this point in the history
  • Loading branch information
petrutlucian94 committed Oct 4, 2024
1 parent a3bc8ce commit 5af1f39
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/k8s/pkg/docgen/godoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func getFieldDocstring(i any, field reflect.StructField, projectDir string) (str

structType := getStructTypeFromDoc(packageDoc, inType.Name())
if structType == nil {
return "", fmt.Errorf("could not find %s structure definition", inType.Name)
return "", fmt.Errorf("could not find %s structure definition", inType.Name())
}

astField := getAstStructField(structType, field.Name)
if astField == nil {
return "", fmt.Errorf("could not find %s.%s field definition", inType.Name, field.Name)
return "", fmt.Errorf("could not find %s.%s field definition", inType.Name(), field.Name)
}

return astField.Doc.Text(), nil
Expand Down
6 changes: 3 additions & 3 deletions src/k8s/pkg/docgen/gomod.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func getGoDepModulePath(name string, version string) (string, error) {
// Validate the path.
if _, err := os.Stat(path); err != nil {
return "", fmt.Errorf(
"Go module path not accessible: %s %s %s. Error: %v.",
"Go module path not accessible: %s %s %s, error: %v.",
name, version, path, err)
}

Expand All @@ -46,11 +46,11 @@ func getGoDepModulePath(name string, version string) (string, error) {
func getDependencyVersionFromGoMod(goModPath string, packageName string, directOnly bool) (string, string, error) {
goModContents, err := os.ReadFile(goModPath)
if err != nil {
return "", "", fmt.Errorf("could not read go.mod file %s. Error: ", goModPath, err)
return "", "", fmt.Errorf("could not read go.mod file %s, error: %v", goModPath, err)
}
goModFile, err := modfile.ParseLax(goModPath, goModContents, nil)
if err != nil {
return "", "", fmt.Errorf("could not parse go.mod file %s. Error: ", goModPath, err)
return "", "", fmt.Errorf("could not parse go.mod file %s, error: %v", goModPath, err)
}

for _, dep := range goModFile.Require {
Expand Down
4 changes: 2 additions & 2 deletions src/k8s/pkg/docgen/json_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func ParseStruct(i any, projectDir string) ([]Field, error) {
inType := reflect.TypeOf(i)

if inType.Kind() != reflect.Struct {
return nil, fmt.Errorf("structure parsing failed, not a structure: %s", inType.Name)
return nil, fmt.Errorf("structure parsing failed, not a structure: %s", inType.Name())
}

outFields := []Field{}
Expand All @@ -98,7 +98,7 @@ func ParseStruct(i any, projectDir string) ([]Field, error) {
docstring, err := getFieldDocstring(i, field, projectDir)
if err != nil {
fmt.Fprintf(os.Stderr, "WARNING: could not retrieve field docstring: %s.%s, error: %v",
inType.Name, field.Name, err)
inType.Name(), field.Name, err)
}

if field.Type.Kind() == reflect.Struct {
Expand Down

0 comments on commit 5af1f39

Please sign in to comment.