generator

package
v0.0.0-...-8f52349 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenImports

func GenImports(pathAlias map[string]string) string

GenImports generates an import declaration from the given map of import:alias pairs. If an alias is blank, then the path is imported directly.

Example
imports := GenImports(map[string]string{
	"os":                 "",
	"some/custom/import": "alias",
})

fmt.Println(imports)
Output:

import (
	"os"
	alias "some/custom/import"
)
Example (Empty)
imports := GenImports(map[string]string{})

fmt.Println(imports)
Output:

func GenLicense

func GenLicense() string

GenLicense generates the license header.

Example
lic := GenLicense()

currentYear := fmt.Sprintf("%d", time.Now().Year())

fmt.Println("license contains year?", strings.Contains(lic, currentYear))
fmt.Println("license contains apache text?", strings.Contains(lic, "Licensed under the Apache License, Version 2.0"))
Output:

license contains year? true
license contains apache text? true

func GenNotice

func GenNotice(file string) string

GenNotice generates a notice that the file was auto-generated.

Example
fmt.Println(GenNotice("some-file.go"))
Output:

// This file was generated with some-file.go, DO NOT EDIT IT.

func TemplateFuncs

func TemplateFuncs() template.FuncMap

TemplateFuncs returns the functions provided by generator available for consumption in a template.

Types

This section is empty.

Jump to

Keyboard shortcuts

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