in config.go [159:203]
func (c *Config) validate() error {
if len(c.Package) == 0 {
return fmt.Errorf("Missing package name")
}
for _, input := range c.Input {
_, err := os.Lstat(input.Path)
if err != nil {
return fmt.Errorf("Failed to stat input path '%s': %v", input.Path, err)
}
}
if len(c.Output) == 0 {
cwd, err := os.Getwd()
if err != nil {
return fmt.Errorf("Unable to determine current working directory.")
}
c.Output = filepath.Join(cwd, "bindata.go")
}
stat, err := os.Lstat(c.Output)
if err != nil {
if !os.IsNotExist(err) {
return fmt.Errorf("Output path: %v", err)
}
// File does not exist. This is fine, just make
// sure the directory it is to be in exists.
dir, _ := filepath.Split(c.Output)
if dir != "" {
err = os.MkdirAll(dir, 0744)
if err != nil {
return fmt.Errorf("Create output directory: %v", err)
}
}
}
if stat != nil && stat.IsDir() {
return fmt.Errorf("Output path is a directory.")
}
return nil
}