Documentation
¶
Index ¶
- Constants
- func FindDefaultProjectFile(directory string) (string, error)
- func FindProjectFile(directory string, fileName string) (string, error)
- func GoPath(directory string) (goPath string, absPath string, err error)
- func GoPaths() []string
- func PackageForPath(directory string) (string, error)
- func Subdirectories(vendor bool, paths ...string) []string
- type Config
- type Contact
- type PathRule
- type Version
Constants ¶
const DefaultProjectFileName = "nirvana.yaml"
DefaultProjectFileName is the default project file name of a nirvana project.
Variables ¶
This section is empty.
Functions ¶
func FindDefaultProjectFile ¶
FindDefaultProjectFile find the path of nirvana.yaml. It will find the path itself and its parents recursively.
func FindProjectFile ¶
FindProjectFile find the path of project file. It will find the path itself and its parents recursively.
func PackageForPath ¶
PackageForPath gets package path for a path.
func Subdirectories ¶
Subdirectories walkthroughs all subdirectories. The results contains itself. If a path is non-existent or not in GOPATH, the path will be ignored.
Types ¶
type Config ¶
type Config struct {
// Root is the directory of this config.
Root string `yaml:"-"`
// Project is project name.
Project string `yaml:"project"`
// Description describes this project.
Description string `yaml:"description"`
// Schemes contains all schemes of APIs.
// Values must be in "http", "https", "ws", "wss".
Schemes []string `yaml:"schemes"`
// Hosts contains the host address to access APIs.
// It's values can be "domain:port" or "ip:port".
Hosts []string `yaml:"hosts"`
// Contacts contains maintainers of this project.
Contacts []Contact `yaml:"contacts"`
// Versions describes API versions.
Versions []Version `yaml:"versions"`
}
Config describes configurations of a project.
func LoadConfig ¶
LoadConfig loads config from yaml file.
func LoadDefaultProjectFile ¶
LoadDefaultProjectFile finds the path of nirvana.yaml and loads it. It will find the directory itself and its parents recursively.
type Contact ¶
type Contact struct {
// Name is maintainer's name.
Name string `yaml:"name"`
// Email is maintainer's email.
Email string `yaml:"email"`
// Description describes the dutis of this maintainer.
Description string `yaml:"description"`
}
Contact describes a project maintainer.
type PathRule ¶
type PathRule struct {
// Prefix indicates a prefix of path.
Prefix string `yaml:"prefix"`
// Regexp is a regular expression. Prefix and Regexp are mutually exclusive.
// If a prefix is specified, this field will be ignored.
Regexp string `yaml:"regexp"`
// Replacement is used to replace path parts matched by Prefix or Regexp.
// In a concrete case, such as we need to export our apis with a gateway. The gateway
// redirects "/component-name/v1" to "/api/v1". Then we should generate api docs and
// clients with prefix "/component-name/v1". Then set Prefix to "/api/v1" and
// Replacement to "/component-name/v1".
Replacement string `yaml:"replacement"`
// contains filtered or unexported fields
}
PathRule describes a path rule.
type Version ¶
type Version struct {
// Name is version number. SemVer is recommended.
Name string `yaml:"name"`
// Description describes this version.
Description string `yaml:"description"`
// Schemes overrides the same field in config.
Schemes []string `yaml:"schemes"`
// Hosts overrides the same field in config.
Hosts []string `yaml:"hosts"`
// Contacts overrides the same field in config.
Contacts []Contact `yaml:"contacts"`
// PathRules contains a list of regexp rules to match path.
PathRules []PathRule `yaml:"rules"`
}
Version describes an API version.