Esempio n. 1
0
func main() {
	log.Default.SetPrefix("gophers: ")

	if err := cmd.RootCmd.Execute(); err != nil {
		log.Fatal(err)
	}
}
Esempio n. 2
0
func init() {
	var err error

	GoBin, err = exec.LookPath("go")
	if err != nil {
		log.Fatal(err)
	}

	GoFmtBin, err = exec.LookPath("gofmt")
	if err != nil {
		log.Fatal(err)
	}

	WD, err = os.Getwd()
	if err != nil {
		log.Fatal(err)
	}

	RootCmd.PersistentFlags().BoolVar(&debugF, "debug", false, "Enable debugging")
}
Esempio n. 3
0
func installPackage() {
	// check go env
	if debugF {
		cmd := exec.Command(GoBin, "env")
		b, err := cmd.CombinedOutput()
		log.Printf(strings.Join(cmd.Args, " "))
		log.Printf("\n%s", b)
		if err != nil {
			log.Fatal(err)
		}
	}

	// install package
	args := []string{"install", "-v"}
	cmd := exec.Command(GoBin, args...)
	log.Printf("Running %s", strings.Join(cmd.Args, " "))
	b, err := cmd.CombinedOutput()
	if err != nil {
		log.Printf("%s", b)
		log.Fatal(err)
	}
}
Esempio n. 4
0
func renderTemplate(data *importData, filename string) {
	path := filepath.Join(data.PackageDir, filename)
	f, err := os.Create(path)
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	err = mainTemplate.Execute(f, data)
	if err != nil {
		log.Fatal(err)
	}

	args := []string{"-s", "-w", path}
	cmd := exec.Command(GoFmtBin, args...)
	log.Printf("Running %s", strings.Join(cmd.Args, " "))
	b, err := cmd.CombinedOutput()
	if err != nil {
		log.Printf("%s", b)
		log.Fatal(err)
	}

	log.Printf("%s created", path)
}
Esempio n. 5
0
func main() {
	flag.Parse()

	L := lua.NewState()
	defer L.Close()

	L.PreloadModule("gophers", glua.NewClient(&http.Client{}).Loader)

	for _, arg := range flag.Args() {
		err := L.DoFile(arg)
		if err != nil {
			log.Fatal(err)
		}
	}
}