fmt
parent
c78214da96
commit
37dd4afc74
@ -1,32 +1,32 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
E_Ok int = iota
|
E_Ok int = iota
|
||||||
E_No_Data
|
E_No_Data
|
||||||
E_No_DB
|
E_No_DB
|
||||||
)
|
)
|
||||||
|
|
||||||
type errorGroup []error
|
type errorGroup []error
|
||||||
|
|
||||||
func (e errorGroup) Error() string {
|
func (e errorGroup) Error() string {
|
||||||
messages := make([]string, 0, len(e))
|
messages := make([]string, 0, len(e))
|
||||||
for i, _ := range e {
|
for i, _ := range e {
|
||||||
messages[i] = e[i].Error()
|
messages[i] = e[i].Error()
|
||||||
}
|
}
|
||||||
return strings.Join(messages, " && ")
|
return strings.Join(messages, " && ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *errorGroup) AddError(err error) {
|
func (g *errorGroup) AddError(err error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if g == nil {
|
if g == nil {
|
||||||
panic("fart")
|
panic("fart")
|
||||||
*g = make([]error, 0, 4)
|
*g = make([]error, 0, 4)
|
||||||
}
|
}
|
||||||
*g = append(*g, err)
|
*g = append(*g, err)
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dataPath = "/projects/exo/expl.speck"
|
var dataPath = "/projects/exo/expl.speck"
|
||||||
|
|
||||||
func log_error(template string, args ...interface{}) {
|
func log_error(template string, args ...interface{}) {
|
||||||
fmt.Fprint(os.Stderr, "ERROR ")
|
fmt.Fprint(os.Stderr, "ERROR ")
|
||||||
fmt.Fprintf(os.Stderr, template+"\n", args...)
|
fmt.Fprintf(os.Stderr, template+"\n", args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func log_info(template string, args ...interface{}) {
|
func log_info(template string, args ...interface{}) {
|
||||||
fmt.Fprint(os.Stdout, "INFO ")
|
fmt.Fprint(os.Stdout, "INFO ")
|
||||||
fmt.Fprintf(os.Stdout, template+"\n", args...)
|
fmt.Fprintf(os.Stdout, template+"\n", args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func bail(status int, template string, args ...interface{}) {
|
func bail(status int, template string, args ...interface{}) {
|
||||||
if status == 0 {
|
if status == 0 {
|
||||||
fmt.Fprintf(os.Stdout, template, args...)
|
fmt.Fprintf(os.Stdout, template, args...)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(os.Stderr, template, args...)
|
fmt.Fprintf(os.Stderr, template, args...)
|
||||||
}
|
}
|
||||||
os.Exit(status)
|
os.Exit(status)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
setupDb()
|
setupDb()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue