Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,12 +598,17 @@ func (pt PredeclaredType) String(map[string]string, string) string { return stri
func (pt PredeclaredType) addImports(map[string]bool) {}

type Field struct {
Name string
Type Type
Name string
Type Type
Anonymous bool
}

func (f *Field) String(pm map[string]string, pkgOverride string) string {
return f.Name + " " + f.Type.String(pm, pkgOverride)
if f.Anonymous {
return f.Type.String(pm, pkgOverride)
} else {
return f.Name + " " + f.Type.String(pm, pkgOverride)
}
}

// StructType is a struct type.
Expand Down Expand Up @@ -885,8 +890,9 @@ func (pkg *Package) unnamedTypeFromType(t reflect.Type) (Type, error) {
}

m := &Field{
Name: ft.Name,
Type: typ,
Name: ft.Name,
Type: typ,
Anonymous: ft.Anonymous,
}

fields = append(fields, m)
Expand Down
12 changes: 12 additions & 0 deletions reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ func runInDir(program []byte, dir string) (*model.PackedPkg, error) {

if modRoot != "" {
MustCopyFile(filepath.Join(modRoot, "go.mod"), filepath.Join(tmpDir, "go.mod"))

// To enable local development of model/model.go, uncomment the following lines
// f, err := os.OpenFile(filepath.Join(tmpDir, "go.mod"), os.O_APPEND|os.O_WRONLY, 0600)
// if err != nil {
// return nil, fmt.Errorf("failed to open go.mod for appending: %v", err)
// }
// defer f.Close()

// replaceDirective := "\n\nreplace github.com/github/depstubber => /Users/owen-mc/workspace/depstubber\n"
// if _, err := f.WriteString(replaceDirective); err != nil {
// return nil, fmt.Errorf("failed to append replace directive to go.mod: %v", err)
// }
}
}

Expand Down