2018-05-19 05:38:51 -04:00
|
|
|
package main
|
|
|
|
|
2018-05-19 05:53:29 -04:00
|
|
|
import (
|
2018-05-25 12:25:55 -04:00
|
|
|
"fmt"
|
2018-05-19 05:53:29 -04:00
|
|
|
"net/url"
|
2018-05-23 11:27:56 -04:00
|
|
|
"os"
|
2018-05-19 05:53:29 -04:00
|
|
|
)
|
|
|
|
|
2018-05-25 12:25:55 -04:00
|
|
|
func logDebug(format string, v ...interface{}) {
|
|
|
|
// Unless the debug flag is specified, discard logs.
|
|
|
|
if *flagDebug {
|
|
|
|
fmt.Printf(format+"\n", v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-19 05:56:02 -04:00
|
|
|
func assert(cond bool, msg string) {
|
2018-05-19 05:38:51 -04:00
|
|
|
if !cond {
|
|
|
|
panic(msg)
|
|
|
|
}
|
|
|
|
}
|
2018-05-19 05:53:29 -04:00
|
|
|
|
2018-05-19 05:56:02 -04:00
|
|
|
func isRemote(filename string) bool {
|
2018-05-19 05:53:29 -04:00
|
|
|
u, err := url.Parse(filename)
|
|
|
|
check(err)
|
|
|
|
return u.IsAbs()
|
|
|
|
}
|
|
|
|
|
|
|
|
func check(e error) {
|
|
|
|
if e != nil {
|
|
|
|
panic(e)
|
|
|
|
}
|
|
|
|
}
|
2018-05-23 11:27:56 -04:00
|
|
|
|
|
|
|
func exitOnError(err error) {
|
|
|
|
if err != nil {
|
|
|
|
os.Stderr.WriteString(err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|