config

package
v0.0.0-...-b478de6 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/palantir/checks/gogenerate/config"
)

func main() {
	yml := `
generators:
  foo:
    go-generate-dir: testbar
    gen-paths:
      names:
        - "bar"
      paths:
        - "testbar/output.txt"
    environment:
      GOOS: darwin
`
	cfg, err := config.LoadFromStrings(yml, "")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%q", fmt.Sprintf("%+v", cfg))
}
Output:

"{Generators:map[foo:{GoGenDir:testbar GenPaths:{Names:[bar] Paths:[testbar/output.txt]} Environment:map[GOOS:darwin]}]}"

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeneratorConfig

type GeneratorConfig struct {
	// GoGenDir is the relative path to the directory in which "go generate" should be run.
	GoGenDir string `yaml:"go-generate-dir" json:"go-generate-dir"`
	// GenPaths is the configuration that specifies the criteria for matching the output files and directories
	// generated by the "go generate" command. Any file or directory that is matched by the matchers are used to
	// determine whether or not the "go generate" command caused any changes.
	GenPaths matcher.NamesPathsCfg `yaml:"gen-paths" json:"gen-paths"`
	// Environment specifies values for the environment variables that should be set for the generator. For example, the
	// following would set GOOS to "darwin" and GOARCH to "amd64":
	//
	//   environment:
	//     GOOS: darwin
	//     GOARCH: amd64
	Environment map[string]string `yaml:"environment" json:"environment"`
}

type Generators

type Generators map[string]GeneratorConfig

func (Generators) SortedKeys

func (g Generators) SortedKeys() []string

type GoGenerate

type GoGenerate struct {
	// Generators is a map from the name of a generator to its configuration.
	Generators Generators `yaml:"generators" json:"generators"`
}

func Load

func Load(configPath, jsonContent string) (GoGenerate, error)

func LoadFromStrings

func LoadFromStrings(ymlContent, _ string) (GoGenerate, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳