ctx

package
Version: v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2021 License: MIT Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGoMod

func IsGoMod(workDir string) (bool, error)

IsGoMod is used to determine whether workDir is a go module project through command `go list -json -m`

Types

type Module

type Module struct {
	Path      string
	Main      bool
	Dir       string
	GoMod     string
	GoVersion string
}

Module contains the relative data of go module, which is the result of the command go list

type ProjectContext

type ProjectContext struct {
	WorkDir string
	// Name is the root name of the project
	// eg: go-zero、greet
	Name string
	// Path identifies which module a project belongs to, which is module value if it's a go mod project,
	// or else it is the root name of the project, eg: github.com/tal-tech/go-zero、greet
	Path string
	// Dir is the path of the project, eg: /Users/keson/goland/go/go-zero、/Users/keson/go/src/greet
	Dir string
}

ProjectContext is a structure for the project, which contains WorkDir, Name, Path and Dir

func Prepare

func Prepare(workDir string) (*ProjectContext, error)

Prepare checks the project which module belongs to,and returns the path and module. workDir parameter is the directory of the source of generating code, where can be found the project path and the project module,

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL