ctx

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: GPL-3.0 Imports: 11 Imported by: 8

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/zeromicro/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
y or Y : Canonical URL