kratos: github.com/bilibili/kratos/tool/protobuf/pkg/project Index | Files

package project

import "github.com/bilibili/kratos/tool/protobuf/pkg/project"

Index

Package Files

project.go

func LookupProjPath Uses

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 Uses

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 Uses

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

Package project imports 6 packages (graph). Updated 2019-05-17. Refresh now. Tools for package owners.