bufgenyaml

package
v0.0.0-...-9c8aaae Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Copyright © 2019 hori-ryota <hori.ryota@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

View Source
var Template = template.Must(template.New("").Funcs(template.FuncMap{
	"LocalPathToGoPackagePath": func(s string) string {
		p, err := gocodeutil.LocalPathToGoPackagePath(s)
		if err != nil {
			panic(err)
		}
		return p
	},
	"ToGoPath": func(s string) string {
		p, err := filepath.Abs(filepath.Dir(filepath.FromSlash(s)))
		if err != nil {
			panic(err)
		}
		gopath := os.Getenv("GOPATH")
		if gopath == "" {
			panic("GOPATH is empty")
		}
		toGoPath, err := filepath.Rel(p, gopath)
		if err != nil {
			panic(err)
		}
		return filepath.ToSlash(toGoPath)
	},
	"Rel": func(base, t string) string {
		rel, err := filepath.Rel(base, t)
		if err != nil {
			panic(err)
		}
		return filepath.ToSlash(rel)
	},
}).Parse(strings.TrimSpace(`
version: v1beta1

plugins:
  - name: go
    out: .
    opt: paths=source_relative
	{{- if .JavaOutputDir}}
  - name: java
    out: {{Rel .OutputDir .JavaOutputDir}}
	{{- end}}
`)))

Functions

func Generate

func Generate(
	outputDir string,
	javaOutputDir string,
) (string, error)

func NewBufgenYamlCmd

func NewBufgenYamlCmd() *cobra.Command

func Run

func Run(
	outputDir string,
	javaOutputDir string,
	useStdOut bool,
) error

Types

type TemplateParam

type TemplateParam struct {
	OutputDir     string
	JavaOutputDir string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL