本文整理汇总了Golang中minilog.Fatal函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatal函数的具体用法?Golang Fatal怎么用?Golang Fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Fatal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
flag.Parse()
logSetup()
log.Debug("using minimega: %v", *f_minimega)
// invoke minimega and get the doc json
doc, err := exec.Command(*f_minimega, "-cli").Output()
if err != nil {
log.Fatalln(err)
}
log.Debug("got doc: %v", string(doc))
// decode the JSON for our template
if err := json.Unmarshal(doc, &handlers); err != nil {
log.Fatalln(err)
}
exclude = strings.Split(*f_exclude, ",")
values = strings.Split(*f_values, ",")
for {
if err := fuzz(); err != nil {
log.Fatal("fuzz: %v", err)
}
if err := cleanup(); err != nil {
log.Fatal("cleanup: %v", err)
}
}
}
示例2: runTests
func runTests() {
mm, err := miniclient.Dial(*f_base)
if err != nil {
log.Fatal("%v", err)
}
if *f_preamble != "" {
out, err := runCommands(mm, *f_preamble)
if err != nil {
log.Fatal("%v", err)
}
log.Info(out)
}
// TODO: Should we quit minimega and restart it between each test?
//quit := mustCompile(t, "quit 2")
files, err := ioutil.ReadDir(*f_testDir)
if err != nil {
log.Fatal("%v", err)
}
for _, info := range files {
if strings.HasSuffix(info.Name(), ".want") || strings.HasSuffix(info.Name(), ".got") {
continue
}
log.Info("Running commands from %s", info.Name())
fpath := path.Join(*f_testDir, info.Name())
got, err := runCommands(mm, fpath)
if err != nil {
log.Fatal("%v", err)
}
// Record the output for offline comparison
if err := ioutil.WriteFile(fpath+".got", []byte(got), os.FileMode(0644)); err != nil {
log.Error("unable to write `%s` -- %v", fpath+".got", err)
}
want, err := ioutil.ReadFile(fpath + ".want")
if err != nil {
log.Error("unable to read file `%s` -- %v", fpath+".want", err)
continue
}
if got != string(want) {
log.Error("got != want for %s", info.Name())
}
//mm.runCommand(quit)
}
}
示例3: cliVmConfigField
func cliVmConfigField(c *minicli.Command, field string) *minicli.Response {
resp := &minicli.Response{Host: hostname}
// If there are no args it means that we want to display the current value
nArgs := len(c.StringArgs) + len(c.ListArgs) + len(c.BoolArgs)
var ok bool
var fns VMConfigFns
var config interface{}
// Find the right config functions, baseConfigFns has highest priority
if fns, ok = baseConfigFns[field]; ok {
config = &vmConfig.BaseConfig
} else if fns, ok = kvmConfigFns[field]; ok {
config = &vmConfig.KVMConfig
} else if fns, ok = containerConfigFns[field]; ok {
config = &vmConfig.ContainerConfig
} else {
log.Fatal("unknown config field: `%s`", field)
}
if nArgs == 0 {
resp.Response = fns.Print(config)
} else {
if err := fns.Update(config, c); err != nil {
resp.Error = err.Error()
}
}
return resp
}
示例4: mustKVMConfig
func mustKVMConfig(val interface{}) *KVMConfig {
if val, ok := val.(*KVMConfig); ok {
return val
}
log.Fatal("`%#v` is not a KVMConfig", val)
return nil
}
示例5: main
func main() {
flag.Usage = usage
flag.Parse()
if *f_version {
fmt.Println("miniccc", version.Revision, version.Date)
fmt.Println(version.Copyright)
os.Exit(0)
}
logSetup()
// signal handling
sig := make(chan os.Signal, 1024)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
// start a ron client
var err error
c, err = ron.NewClient(*f_port, *f_parent, *f_serial, *f_path)
if err != nil {
log.Fatal("creating ron node: %v", err)
}
log.Debug("starting ron client with UUID: %v", c.UUID)
go client()
<-sig
// terminate
}
示例6: ProcessCommand
// Process a prepopulated Command
func ProcessCommand(c *Command) <-chan Responses {
if !c.noOp && c.Call == nil {
log.Fatal("command %v has no callback!", c)
}
respChan := make(chan Responses)
go func() {
if !c.noOp {
c.Call(c, respChan)
}
// Append the command to the history
if c.Record {
history = append(history, c.Original)
if len(history) > HistoryLen && HistoryLen > 0 {
if firstHistoryTruncate {
log.Warn("history length exceeds limit, truncating to %v entries", HistoryLen)
firstHistoryTruncate = false
}
history = history[len(history)-HistoryLen:]
}
}
close(respChan)
}()
return respChan
}
示例7: mustContainerConfig
func mustContainerConfig(val interface{}) *ContainerConfig {
if val, ok := val.(*ContainerConfig); ok {
return val
}
log.Fatal("`%#v` is not a ContainerConfig", val)
return nil
}
示例8: unmangleUUID
func unmangleUUID(uuid string) string {
// string must be in the form:
// XXXXXXXX-XXXX-XXXX-YYYY-YYYYYYYYYYYY
// the X characters are reversed at 2 byte intervals (big/little endian for a uuid?)
var ret string
re := regexp.MustCompile("[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}")
u := re.FindString(strings.ToLower(uuid))
if uuid == "" {
log.Fatal("uuid failed to match uuid format: %v", uuid)
}
log.Debug("found uuid: %v", u)
if getOSVer() != "Windows XP" {
return u
}
ret += u[6:8]
ret += u[4:6]
ret += u[2:4]
ret += u[:2]
ret += "-"
ret += u[11:13]
ret += u[9:11]
ret += "-"
ret += u[16:18]
ret += u[14:16]
ret += u[18:]
log.Debug("mangled/unmangled uuid: %v %v", u, ret)
return ret
}
示例9: runCommandGlobally
// Wrapper for minicli.ProcessCommand for commands that use meshage.
// Specifically, for `mesh send all ...`, runs the subcommand locally and
// across meshage, combining the results from the two channels into a single
// channel. This is useful if you want to get the output of a command from all
// nodes in the cluster without having to run a command locally and over
// meshage.
func runCommandGlobally(cmd *minicli.Command) chan minicli.Responses {
// Keep the original CLI input
original := cmd.Original
record := cmd.Record
cmd, err := minicli.Compilef("mesh send %s .record %t %s", Wildcard, record, original)
if err != nil {
log.Fatal("cannot run `%v` globally -- %v", original, err)
}
cmd.Record = record
cmdLock.Lock()
var wg sync.WaitGroup
out := make(chan minicli.Responses)
cmd, err = cliPreprocessor(cmd)
if err != nil {
log.Errorln(err)
out <- minicli.Responses{
&minicli.Response{
Host: hostname,
Error: err.Error(),
},
}
close(out)
return out
}
// Run the command (should be `mesh send all ...` and the subcommand which
// should run locally).
ins := []chan minicli.Responses{
minicli.ProcessCommand(cmd),
minicli.ProcessCommand(cmd.Subcommand),
}
// De-mux ins into out
for _, in := range ins {
wg.Add(1)
go func(in chan minicli.Responses) {
defer wg.Done()
for v := range in {
out <- v
}
}(in)
}
// Wait until everything has been read before closing the chan and
// releasing the lock.
go func() {
defer cmdLock.Unlock()
defer close(out)
wg.Wait()
}()
return out
}
示例10: registerHandlers
// registerHandlers registers all the provided handlers with minicli, panicking
// if any of the handlers fail to register.
func registerHandlers(name string, handlers []minicli.Handler) {
for i := range handlers {
err := minicli.Register(&handlers[i])
if err != nil {
log.Fatal("invalid handler, %s:%d -- %v", name, i, err)
}
}
}
示例11: MustCompile
// MustCompile compiles the string, calling log.Fatal if the string is not a
// valid command. Should be used when providing a known command rather than
// processing user input.
func MustCompile(input string) *Command {
c, err := Compile(input)
if err != nil {
log.Fatal("unable to compile `%s` -- %v", input, err)
}
return c
}
示例12: registerTID
// register a transaction ID, adding a return channel to the mux
func (t *Tunnel) registerTID(TID int32) chan *tunnelMessage {
if _, ok := t.tids[TID]; ok {
log.Fatal("tid %v already exists!", TID)
}
c := make(chan *tunnelMessage, 1024)
t.tids[TID] = c
return c
}
示例13: Run
// Run a command through a JSON pipe, hand back channel for responses.
func (mm *Conn) Run(cmd *minicli.Command) chan *Response {
if cmd == nil {
// Language spec: "Receiving from a nil channel blocks forever."
// Instead, make and immediately close the channel so that range
// doesn't block and receives no values.
out := make(chan *Response)
close(out)
return out
}
err := mm.enc.Encode(*cmd)
if err != nil {
log.Fatal("local command gob encode: %v", err)
}
log.Debugln("encoded command:", cmd)
respChan := make(chan *Response)
go func() {
defer close(respChan)
for {
var r Response
err = mm.dec.Decode(&r)
if err != nil {
if err == io.EOF {
log.Fatal("server disconnected")
}
log.Fatal("local command gob decode: %v", err)
}
respChan <- &r
if !r.More {
log.Debugln("got last message")
break
} else {
log.Debugln("expecting more data")
}
}
}()
return respChan
}
示例14: mustFindMask
// mustFindMask returns the index of the specified mask in vmMasks. If the
// specified mask is not found, log.Fatal is called.
func mustFindMask(mask string) int {
for i, v := range vmMasks {
if v == mask {
return i
}
}
log.Fatal("missing `%s` in vmMasks", mask)
return -1
}
示例15: getUUID
func getUUID() string {
out, err := exec.Command("wmic", "path", "win32_computersystemproduct", "get", "uuid").CombinedOutput()
if err != nil {
log.Fatal("wmic run: %v", err)
}
uuid := unmangleUUID(strings.TrimSpace(string(out)))
log.Debug("got UUID: %v", uuid)
return uuid
}