Back to

Package project

Latest Go to latest

The latest major version is .

Published: Jan 20, 2020 | License: MIT | Module:


func LookupProjPath

func LookupProjPath(protoAbs string) (result string)

LookupProjPath get project path by proto absolute path assume that proto is in the project's api directory

type ProjectInfo

type ProjectInfo struct {
	// AbsolutePath of the project
	AbsolutePath string
	// ImportPath of project
	ImportPath string
	// dir name of project
	Name string
	// parent dir of project, maybe empty
	Department string
	// grandma dir of project , maybe empty
	Typ            string
	HasInternalPkg bool
	// 从工作目录(working directory)到project目录的相对路径 比如a/b .. ../a
	// 作用是什么?
	// 假设目录结构是
	// -project
	//   - api/api.proto
	//   - internal/service
	// 我想在 internal/service下生成一个文件 service.go
	// work-dir 为 project/api
	// proto 生成命令为 protoc --xx_out=. api.proto
	// 那么在 protoc plugin 中的文件输出路径就得是 ../internal/service/ => {pathRefToProj}internal/service
	PathRefToProj string

if proto file is inside a project (that has a /api directory) this present a project info 必须假设proto文件的路径就是相对work-dir的路径,否则无法找到proto文件以及对应的project

func NewProjInfo

func NewProjInfo(file string, modDirName string, modImportPath string) (projInfo *ProjectInfo, err error)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier