Skip to content

Commit

Permalink
chore: add package and module struct fields comments
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed Oct 11, 2024
1 parent 53c5770 commit 457b0c9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
23 changes: 0 additions & 23 deletions gnovm/pkg/packages/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,23 +361,6 @@ func fillPackage(meta *PackageSummary) (*Package, error) {
}, nil
}

type Package struct {
Dir string `json:",omitempty"`
ImportPath string `json:",omitempty"`
Name string `json:",omitempty"`
Root string `json:",omitempty"`
Module Module `json:",omitempty"`
Match []string `json:",omitempty"`
GnoFiles []string `json:",omitempty"`
Imports []string `json:",omitempty"`
Deps []string `json:",omitempty"`
TestGnoFiles []string `json:",omitempty"`
TestImports []string `json:",omitempty"`
FiletestGnoFiles []string `json:",omitempty"`
FiletestImports []string `json:",omitempty"`
Errors []error `json:",omitempty"`
}

func (p *Package) MemPkg() (*std.MemPackage, error) {
allFiles := append(p.GnoFiles, p.TestGnoFiles...)
allFiles = append(allFiles, p.FiletestGnoFiles...)
Expand All @@ -399,12 +382,6 @@ func (p *Package) MemPkg() (*std.MemPackage, error) {
}, nil
}

type Module struct {
Path string `json:",omitempty"`
Dir string `json:",omitempty"`
GnoMod string `json:",omitempty"`
}

func resolveNameAndImports(gnoFiles []string) (string, []string, error) {
names := map[string]int{}
imports := map[string]struct{}{}
Expand Down
26 changes: 26 additions & 0 deletions gnovm/pkg/packages/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package packages

// ported from https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/cmd/go/internal/load/pkg.go
type Package struct {
Dir string `json:",omitempty"` // directory containing package sources
ImportPath string `json:",omitempty"` // import path of package in dir
Name string `json:",omitempty"` // package name
Root string `json:",omitempty"` // Go root, Go path dir, or module root dir containing this package
Module Module `json:",omitempty"` // info about package's module, if any
Match []string `json:",omitempty"` // command-line patterns matching this package
GnoFiles []string `json:",omitempty"` // .gno source files (TestGnoFiles, FiletestGnoFiles)
Imports []string `json:",omitempty"` // import paths used by this package
Deps []string `json:",omitempty"` // all (recursively) imported dependencies
TestGnoFiles []string `json:",omitempty"` // _test.gno files in package
TestImports []string `json:",omitempty"` // imports from TestGnoFiles
FiletestGnoFiles []string `json:",omitempty"` // _filetest.gno files in package
FiletestImports []string `json:",omitempty"` // imports from FiletestGnoFiles
Errors []error `json:",omitempty"` // error loading this package (not dependencies)
}

// ported from https://cs.opensource.google/go/go/+/refs/tags/go1.23.2:src/cmd/go/internal/modinfo/info.go
type Module struct {
Path string `json:",omitempty"` // module path
Dir string `json:",omitempty"` // directory holding local copy of files, if any
GnoMod string `json:",omitempty"` // path to gno.mod file describing module, if any
}

0 comments on commit 457b0c9

Please sign in to comment.