當前位置: 首頁>>代碼示例>>Golang>>正文


Golang minilog.Fatal函數代碼示例

本文整理匯總了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)
		}
	}
}
開發者ID:cdshann,項目名稱:minimega,代碼行數:31,代碼來源:main.go

示例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)
	}
}
開發者ID:npe9,項目名稱:minimega,代碼行數:54,代碼來源:main.go

示例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
}
開發者ID:jenareljam,項目名稱:minimega,代碼行數:31,代碼來源:vm_cli.go

示例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
}
開發者ID:jenareljam,項目名稱:minimega,代碼行數:7,代碼來源:vmconfig.go

示例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
}
開發者ID:npe9,項目名稱:minimega,代碼行數:30,代碼來源:main.go

示例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
}
開發者ID:cdshann,項目名稱:minimega,代碼行數:32,代碼來源:minicli.go

示例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
}
開發者ID:jenareljam,項目名稱:minimega,代碼行數:7,代碼來源:vmconfig.go

示例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
}
開發者ID:cdshann,項目名稱:minimega,代碼行數:33,代碼來源:uuid_windows.go

示例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
}
開發者ID:jenareljam,項目名稱:minimega,代碼行數:65,代碼來源:cli.go

示例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)
		}
	}
}
開發者ID:ITLivLab,項目名稱:minimega,代碼行數:10,代碼來源:misc.go

示例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
}
開發者ID:cdshann,項目名稱:minimega,代碼行數:11,代碼來源:minicli.go

示例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
}
開發者ID:npe9,項目名稱:minimega,代碼行數:9,代碼來源:minitunnel.go

示例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
}
開發者ID:cdshann,項目名稱:minimega,代碼行數:46,代碼來源:minimega.go

示例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
}
開發者ID:ITLivLab,項目名稱:minimega,代碼行數:12,代碼來源:vm.go

示例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
}
開發者ID:cdshann,項目名稱:minimega,代碼行數:11,代碼來源:uuid_windows.go


注:本文中的minilog.Fatal函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。