This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os/exec" | |
"strings" | |
"fmt" | |
) | |
func runProgram1(program string, args ...string) (string, error) { | |
outStrings, err := runProgram(program, args...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"bufio" | |
) | |
func readFirstLineFromFile(path string) (string, error) { | |
file, err := os.Open(path) | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"flag" | |
"path/filepath" | |
) | |
func usage() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"log" | |
"os" | |
"strings" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"os" | |
"path/filepath" | |
) | |
func main() { | |
searchDir, err := os.Getwd() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "strconv" | |
func interfaceToFloat(value interface{}) float64 { | |
if value == nil { | |
return 0.0 | |
} | |
switch typedValue := value.(type) { | |
case float64: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"path/filepath" | |
) | |
func fileNameWithoutPath(fileName string) string { | |
return filepath.Base(fileName) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "path" | |
func filenameDirectory(filename string) string { | |
return path.Dir(filename) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "os" | |
func fileExists(reqFilePath string) bool { | |
_, err := os.Stat(reqFilePath) | |
exists := false | |
if err == nil { | |
exists = true | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func determineImageType(fileName string) (imageType string, err error) { | |
return runProgram1("identify", "-format", "%[m]", fmt.Sprintf("%v[0]", fileName)) | |
} |