func main() {
	flag.Usage = Usage
	flag.Parse()
	if len(flag.Args()) != 1 {
		Usage()
	}

	// Read and parse the input.
	name := flag.Args()[0]
	tmpl := template.New(name).Funcs(template.FuncMap{"code": code})
	if _, err := tmpl.ParseFile(name); err != nil {
		log.Fatal(err)
	}

	// Execute the template.
	if err := tmpl.Execute(os.Stdout, 0); err != nil {
		log.Fatal(err)
	}
}
Beispiel #2
0
			return
		}
	}
	return matchRe.MatchString(str), nil
}

func main() {
	testing.Main(matchString, tests, benchmarks)
}

`)
	return t
}()
*/
var TestmainTemplateExp = func() *template.Template {
	t := template.New("testmain")
	err := t.Parse(
		`package main

{{range .TestPkgs}}import {{.PkgAlias}} "{{.PkgTarget}}"
{{end}}
import "testing"
import __os__ "os"
import __regexp__ "regexp"

var tests = []testing.InternalTest{
{{range .TestPkgs}}{{if $PkgName=.PkgName}}{{if $PkgAlias=.PkgAlias}}{{range .TestFuncs}}	{"{{$PkgName}}.{{.}}", {{$PkgAlias}}.{{.}}},{{end}}{{end}}{{end}}{{end}}
}

var benchmarks = []testing.InternalBenchmark{
{{range .TestPkgs}}{{if $PkgName=.PkgName}}{{if $PkgAlias=.PkgAlias}}{{range .TestBenchmarks}}	{"{{$PkgName}}.{{.}}", {{$PkgAlias}}.{{.}}},{{end}}{{end}}{{end}}{{end}}
Beispiel #3
0
# gb: copy to local install
$(GBROOT)/{BuildDirCmd}/$(TARG): $(TARG)
	mkdir -p $(dir $@); cp -f $< $@
command: $(GBROOT)/bin/$(TARG)
{.section LocalDeps}

# gb: local dependencies
{.repeated section LocalDeps}$(TARG): $(GBROOT)/{BuildDirPkg}/{@}.a
{.end}
{.end}
`,
	nil)
*/
var MakeCmdTemplateExp = func() *template.Template {
	t := template.New("MakeCmd")
	err := t.Parse(
		`# Makefile generated by gb: http://go-gb.googlecode.com
# gb provides configuration-free building and distributing

include $(GOROOT)/src/Make.inc

TARG={{.Target}}
GOFILES=\
{{range .GoFiles}}	{{.}}\
{{end}}
# gb: this is the local install
GBROOT={{.GBROOT}}

# gb: compile/link against local install
GC+= -I $(GBROOT)/_obj