Exemple #1
0
func main() {
	for i, arg := range os.Args {
		if i == 0 {
			continue
		}
		search := arg
		if info, err := os.Stat(arg); err == nil && info.IsDir() {
			search = fmt.Sprintf("%s/*.tf", arg)
		}
		files, err := filepath.Glob(search)
		if err != nil {
			colorstring.Printf("[red]Error finding files: %s", err)
		}
		for _, filename := range files {
			fmt.Printf("Checking %s ... ", filename)
			file, err := ioutil.ReadFile(filename)
			if err != nil {
				colorstring.Printf("[red]Error reading file: %s\n", err)
				break
			}
			_, err = hcl.Parse(string(file))
			if err != nil {
				colorstring.Printf("[red]Error parsing file: %s\n", err)
				break
			}
			colorstring.Printf("[green]OK!\n")
		}
	}

}
Exemple #2
0
func Debug() {
	colorstring.Printf("[blue]Debug Information.\n")
	colorstring.Printf("    [blue]Environment:\n")
	for _, val := range env.OsEnv {
		fmt.Printf("      - %s \n", val)
	}
	colorstring.Printf("    [cyan]Go Specific:\n")
	fmt.Println("      - GO Version: ", env.RunEnv.GoVersion)
	fmt.Println("      - GO Operating System(GOOS): ", env.RunEnv.GoOs)
	fmt.Println("      - GO Root(GOROOT): ", env.RunEnv.GoRoot)
	fmt.Println("      - GO Processors: ", env.RunEnv.NumCPU)
	colorstring.Printf("    [green]Config:\n")
	spew.Dump(env.Cfg)
	// for k, v := range m {
	//     fmt.Println("     - %v = %v", k, v)
	// }
}