• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang lg.Fatal函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/thomasf/lg.Fatal函数的典型用法代码示例。如果您正苦于以下问题:Golang Fatal函数的具体用法?Golang Fatal怎么用?Golang Fatal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Fatal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: RecentSuggestionSessions

func (d *DB) RecentSuggestionSessions(n uint64) ([]tokenData, error) {
	psql := squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar)
	q := psql.
		Select("token", "created_at", "data::json->'URL'").
		From("samples").
		Where(squirrel.Eq{"type": "NewClientToken"}).
		OrderBy("ID desc").
		Limit(n)

	rows, err := q.RunWith(d.cache).Query()
	if err != nil {
		lg.Fatal(err)
	}
	defer rows.Close()
	var tokens []tokenData
	for rows.Next() {
		var token tokenData
		var ID string
		err := rows.Scan(&ID, &token.CreatedAt, &token.URL)
		if err != nil {
			lg.Fatal(err)
		}
		token.ID = shared.SuggestionToken(ID)
		tokens = append(tokens, token)
	}
	return tokens, nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:27,代码来源:postgres.go


示例2: Init

// Init initializes the server.
func Init() error {
	lg.SetSrcHighlight("alkasir/cmd", "alkasir/pkg")
	lg.CopyStandardLogTo("INFO")
	lg.V(1).Info("Log v-level:", lg.Verbosity())
	lg.V(1).Info("Active country codes:", shared.CountryCodes)
	lg.Flush()

	if *datadirFlag == "" {
		u, err := user.Current()
		if err != nil {
			lg.Fatal(err)
		}
		datadir = filepath.Join(u.HomeDir, ".alkasir-central")
	} else {
		datadir = *datadirFlag
	}

	validCountryCodes = make(map[string]bool, len(shared.CountryCodes))
	validCountryCodesMu.Lock()
	for _, cc := range shared.CountryCodes {
		validCountryCodes[cc] = true
	}
	validCountryCodesMu.Unlock()

	err := InitDB()
	if err != nil {
		lg.Fatalln(err)
		return err
	}
	redisPool = newRedisPool(*redisServer, *redisPassword)

	internet.SetDataDir(filepath.Join(datadir, "internet"))

	countryFile := filepath.Join(datadir, "internet", "GeoLite2-Country.mmdb")
	if _, err := os.Stat(countryFile); os.IsNotExist(err) {
		// http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz
		lg.Fatalf("cannot enable IP2CountryCode lookups, %s is missing", countryFile)
	} else {
		var err error
		mmCountryDB, err = maxminddb.Open(countryFile)
		if err != nil {
			lg.Fatal(err)
		}
	}

	cityFile := filepath.Join(datadir, "internet", "GeoLite2-City.mmdb")
	if _, err := os.Stat(cityFile); os.IsNotExist(err) {
		// http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
		lg.Warningf("cannot enable IP2CityGeoNameID lookups, %s is missing", cityFile)
	} else {
		mmCityDB, err = maxminddb.Open(cityFile)
		if err != nil {
			lg.Fatal(err)
		}
		// defer mmCityDB.Close()
	}

	return nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:60,代码来源:central.go


示例3: RunPatchesCreate

func RunPatchesCreate(queries []nexus.BuildQuery, privateKey string, publicKey string, nWorkers int) ([]CreatePatchResult, error) {
	if nWorkers < 1 {
		nWorkers = 1
	}
	jobC := make(chan CreatePatchJob, 6)

	var creators sync.WaitGroup
	for _, v := range queries {
		creators.Add(1)
		go func(b nexus.BuildQuery) {
			defer creators.Done()
			err := createJobs(b, jobC, privateKey, publicKey)
			if err != nil {
				lg.Fatal(err)
			}
		}(v)

	}
	resC := make(chan CreatePatchResult, 0)
	var differs sync.WaitGroup
	for workerN := 0; workerN < nWorkers; workerN++ {
		differs.Add(1)
		go func() {
			defer differs.Done()
			for job := range jobC {
				res, err := CreatePatch(job)
				if err != nil {
					lg.Fatal(err)
				}
				resC <- res
			}
		}()
	}

	go func() {
		creators.Wait()
		close(jobC)
		differs.Wait()
		close(resC)
	}()

	var patches []CreatePatchResult
	defer func() {
		for _, p := range patches {
			os.Remove(p.job.NewBinary)
			os.Remove(p.job.OldBinary)

		}
	}()
	for pr := range resC {
		patches = append(patches, pr)

	}

	return patches, nil
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:56,代码来源:makepatch.go


示例4: GetRelatedHosts

func (d *DB) GetRelatedHosts() (map[string][]string, error) {
	result := make(map[string][]string, 0)
	psql := squirrel.StatementBuilder.PlaceholderFormat(squirrel.Dollar)
	s := psql.Select("host", "related").From("hosts_related")
	rows, err := s.RunWith(d.cache).Query()
	if err != nil {
		logSQLErr(err, &s)
		return nil, err
	}
	defer rows.Close()

	for rows.Next() {
		var host, related string
		err := rows.Scan(&host, &related)
		if err != nil {
			lg.Fatal(err)
		}
		if relateds, ok := result[host]; ok {
			relateds = append(relateds, related)
			result[host] = relateds
		} else {
			relateds := make([]string, 1)
			relateds = append(relateds, related)
			result[host] = relateds
		}
	}
	return result, nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:28,代码来源:postgres.go


示例5: main

func main() {
	mrand.Seed(time.Now().UnixNano())
	errors := []error{
		flag.Set("logtostderr", "true"),
		flag.Set("logcolor", "true"),
	}
	for _, err := range errors {
		if err != nil {
			panic(err)
		}
	}
	lg.SetSrcHighlight("alkasir/cmd", "alkasir/pkg")
	lg.CopyStandardLogTo("info")
	flag.Parse()
	flagenv.Prefix = "ALKASIR_"
	flagenv.Parse()
	err := commandHandler(flag.Args())
	if err != nil {
		if err == errCommandNotFound {
			fmt.Println("")
			fmt.Println("Command index:")
			fmt.Println("")
			rootCommand.PrintHelp("alkasir-admin", 0)
			fmt.Println("")
			os.Exit(1)
		}
		lg.Fatal(err)
		os.Exit(1)
	}

}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:31,代码来源:alkasir-admin.go


示例6: GenerateKeys

func GenerateKeys(random io.Reader) (*[64]byte, *[32]byte) {
	pub, priv, err := ed25519.GenerateKey(random)
	if err != nil {
		lg.Fatal(err)
	}
	return priv, pub
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:7,代码来源:upgradebin.go


示例7: startMonitoring

func startMonitoring(addr string) {

	var redisActiveConn = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "redis_active_conn",
		Help: "Number of active redis connections.",
	})
	prometheus.MustRegister(redisActiveConn)

	var redisMaxConn = prometheus.NewGauge(prometheus.GaugeOpts{
		Name: "redis_max_conn",
		Help: "Maximum number of redis connections.",
	})
	prometheus.MustRegister(redisMaxConn)

	http.Handle("/metrics", prometheus.Handler())
	redisMaxConn.Set(float64(redisPool.MaxActive))
	go func() {
		tick := time.NewTicker(1 * time.Second)
		for range tick.C {
			if redisPool == nil {
				redisActiveConn.Set(0)
			} else {
				redisActiveConn.Set(float64(redisPool.ActiveCount()))
			}
		}
	}()
	err := http.ListenAndServe(addr, nil)
	if err != nil {
		lg.Fatal(err)
	}
}
开发者ID:thomasf,项目名称:alkasir,代码行数:31,代码来源:central.go


示例8: debugPprof

func debugPprof(args []string) error {
	var dir string
	if len(args) == 0 {
		dir = debugLatestImport()
	} else {
		dir = args[0]
	}

	const profile = "heap"

	var header debugexport.DebugHeader
	data, err := ioutil.ReadFile(filepath.Join(dir, "header.json"))
	if err != nil {
		lg.Fatal(err)
	}

	err = json.Unmarshal(data, &header)
	if err != nil {
		lg.Fatal(err)
	}
	lg.Infof("%+v", header)
	q := nexus.BuildQuery{
		OS:      header.OS,
		Arch:    header.Arch,
		Version: header.Version,
		Cmd:     "alkasir-gui",
	}
	cmdlocation, err := q.GetMatchingBuildBinary()
	if err != nil {
		lg.Fatal(err)
	}

	var cmdargs []string
	cmdargs = append(cmdargs,
		"tool",
		"pprof",
		cmdlocation,
		filepath.Join(dir, profile+".txt"))
	cmd := exec.Command("go", cmdargs...)
	cmd.Stdout = os.Stdout
	cmd.Stdin = os.Stdin
	cmd.Stderr = os.Stderr
	return cmd.Run()

}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:45,代码来源:alkasir-admin.go


示例9: Read

func Read(bank int) ([]omron.Entry, error) {
	counted := C.m_count(C.int(bank))
	var entries []omron.Entry
	for i := 0; i < int(counted)+1; i++ {
		ret := C.m_read(C.int(bank), C.int(i))
		str := C.GoString(ret)
		C.free(unsafe.Pointer(ret))
		if str == "" {
			fmt.Print(".")
		} else {
			fmt.Print("*")
			fields := strings.Split(str, ",")
			t, err := time.ParseInLocation("2006-01-02 15:04:05", fields[0], time.Local)
			if err != nil {
				lg.Fatal(err)
			}
			sys, err := strconv.Atoi(fields[1])
			if err != nil {
				lg.Fatal(err)
			}
			dia, err := strconv.Atoi(fields[2])
			if err != nil {
				lg.Fatal(err)
			}
			pulse, err := strconv.Atoi(fields[3])
			if err != nil {
				lg.Fatal(err)
			}
			entry := omron.Entry{
				Time:  t,
				Sys:   sys,
				Dia:   dia,
				Pulse: pulse,
				Bank:  bank,
			}
			entries = append(entries, entry)
		}
	}
	fmt.Print("\n")

	return entries, nil
}
开发者ID:thomasf,项目名称:bpchart,代码行数:42,代码来源:readc.go


示例10: QuickReleaseRunner

// Quickrunner for the latest archived release
func QuickReleaseRunner(cmd string) {
	q := BuildQuery{
		OS:   runtime.GOOS,
		Arch: runtime.GOARCH,
		Cmd:  cmd,
	}

	artifacts, err := q.GetVersions()
	latest := artifacts.Latest()
	q.GetBinary(latest)
	bin, err := q.cmdGlob()
	if err != nil {
		lg.Fatal(err)
	}

	err = latest.Run(bin)
	if err != nil {
		lg.Fatal(err)
	}
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:21,代码来源:nexus.go


示例11: testPatch

func testPatch(pr CreatePatchResult, publicKey string) error {
	lg.Infof("verifying %s   %s>%s", pr.Artifact, pr.OldVersion, pr.NewVersion)
	tmpfile := fmt.Sprintf("/tmp/%s-%s-o", pr.Artifact, pr.OldVersion)
	err := cp(tmpfile, pr.job.OldBinary)
	if err != nil {
		lg.Fatal(err)
	}

	defer func() {
		err = os.Remove(tmpfile)
		if err != nil {
			lg.Errorln(err)
		}
	}()

	sum, err := base64.RawURLEncoding.DecodeString(pr.SHA256Sum)
	if err != nil {
		return err
	}

	sig, err := upgradebin.DecodeSignature(pr.ED25519Signature)
	if err != nil {
		return err
	}
	pub, err := upgradebin.DecodePublicKey([]byte(publicKey))
	if err != nil {
		return err
	}

	opts := update.Options{
		Patcher:    update.NewBSDiffPatcher(),
		Verifier:   upgradebin.NewED25519Verifier(),
		Hash:       crypto.SHA256,
		Checksum:   sum,
		Signature:  sig[:],
		PublicKey:  pub,
		TargetPath: tmpfile,
	}

	diffFile, err := os.Open(pr.DiffFile)
	if err != nil {
		return err
	}
	defer diffFile.Close()

	err = update.Apply(diffFile, opts)
	if err != nil {
		return err
	}

	return nil
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:52,代码来源:makepatch.go


示例12: startAnalysis

func startAnalysis(clients db.Clients) {
	go func() {
		tick := time.NewTicker(10 * time.Second)

		lastID, err := clients.DB.GetLastProcessedSampleID()
		if err != nil {
			lg.Warningln(err)
		}
		lg.Infof("starting analysis from sample ID %d", lastID)

		lastPersistedID := lastID

		for range tick.C {
			results, err := clients.DB.GetSamples(uint64(lastID), "")
			if err != nil {
				lg.Fatal(err)
			}
			n := 0
			start := time.Now()
		loop:
			for s := range results {
				n++
				if s.ID > lastID {
					lastID = s.ID
				}
				if s.Type == "NewClientToken" {
					if !shared.AcceptedHost(s.Host) {
						lg.Warningln("not accepted host id:", s.ID, s.Host)
						continue loop
					}
					err := clients.DB.PublishHost(s)
					if err != nil {
						lg.Warning(err)
					}
				}
			}
			if n != 0 && lg.V(15) {
				lg.Infof("processed %d samples in %s", n, time.Since(start).String())
			}
			if lastID != lastPersistedID {
				err = clients.DB.SetLastProcessedSampleID(lastID)
				if err != nil {
					lg.Errorln(err)
				} else {
					lastPersistedID = lastID
				}
			}
		}
	}()
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:50,代码来源:analysis.go


示例13: update

func (r *relatedHosts) update() {
	lg.V(19).Infoln("updating related hosts..")
	related, err := r.dbclients.DB.GetRelatedHosts()
	if err != nil {
		lg.Fatal(err)
	}
	curated := make(map[string][]string, len(related))
	for k, v := range related {
		curated[strings.TrimPrefix(k, "www.")] = v
	}
	r.Lock()
	r.items = curated
	r.Unlock()
}
开发者ID:thomasf,项目名称:alkasir,代码行数:14,代码来源:api.go


示例14: main

func main() {
	runtime.LockOSThread()
	flag.Set("logtostderr", "true")
	lg.CopyStandardLogTo("INFO")
	lg.SetSrcHighlight("libomron")
	flag.Parse()

	bdb, err := bolt.Open("bpchart.db", 0600, &bolt.Options{Timeout: 1 * time.Second})
	if err != nil {
		lg.Fatal(err)
	}
	db := &db.DB{DB: bdb, BucketName: []byte(entriesBucketName)}

	var wg sync.WaitGroup

	wg.Add(1)
	go func() {
		lg.Fatal(httpServer(db))
		wg.Done()
	}()

	wg.Add(1)
	go func() {

		if FAKE {
			err = fakeImportFromDevice(db)
		} else {
			err = importFromDevice(db)
		}
		if err != nil {
			lg.Errorln(err)
		}
		wg.Done()
	}()

	wg.Wait()
}
开发者ID:thomasf,项目名称:bpchart,代码行数:37,代码来源:main.go


示例15: wait

// Wait blocks until the underlying process is stopped
func (s *Service) wait() {
	if s.isCopy {
		lg.Fatal("wait called on copy of service!")
	}
	if s.cmd != nil {
		lg.V(10).Infof("Waiting for process %s to exit", s.ID)
		err := s.cmd.Wait()
		if err != nil {
			lg.Warningln(err)
		}
		lg.V(10).Infof("%s exited", s.ID)
	}
	s.waiter.Wait()

}
开发者ID:thomasf,项目名称:alkasir,代码行数:16,代码来源:service.go


示例16: debugLatestImport

func debugLatestImport() string {
	files, err := ioutil.ReadDir("alkasir-debug-reports")
	if err != nil {
		lg.Fatal(err)
	}

	var dirs []string
	for _, v := range files {
		if v.IsDir() {
			dirs = append(dirs, v.Name())
		}
	}
	sort.Strings(dirs)
	return filepath.Join("alkasir-debug-reports", dirs[len(dirs)-1])
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:15,代码来源:alkasir-admin.go


示例17: NewService

// Create a new service instance.
// note: name is not yet a decided requirement.
func NewService(name string) (s *Service) {

	s = &Service{
		ID:       serviceIdGen.New(),
		Name:     name,
		Request:  make(map[string]string),
		Response: make(map[string]string),
		Methods: &Methods{
			list: make([]*Method, 0),
		},
	}
	err := ManagedServices.add(s)
	if err != nil {
		lg.Fatal(err)
	}
	return
}
开发者ID:thomasf,项目名称:alkasir,代码行数:19,代码来源:service.go


示例18: GetBinary

// GetBinary downloads artifact, extracts archive and returns the path to the
// extracted executable. If the file already exits it is not downloaded.
func (q *BuildQuery) GetBinary(artifact *Artifact) (string, error) {
	cmdGlob, err := q.cmdGlob()
	if err != nil {
		return "", err
	}

	if _, err := os.Stat(artifact.Path()); os.IsNotExist(err) {
		err = artifact.Download()
		if err != nil {
			lg.Fatal(err)
		}
	}
	gp, err := artifact.GlobPath(cmdGlob)
	if err != nil {
		return "", err
	}

	if len(gp) > 0 {
		return gp[0], nil
	}

	err = artifact.Extract()
	if err != nil {
		// retry download if extraction fails
		err = artifact.Download()
		if err != nil {
			return "", err

		}
		err := artifact.Extract()
		if err != nil {
			return "", err
		}
	}

	gp, err = artifact.GlobPath(cmdGlob)
	if err != nil {
		return "", err
	}

	if len(gp) < 1 {
		lg.Fatalf("no glob match for '%s' in %s %s", cmdGlob, artifact.Version, q.ArtifactDisplayName())
	}
	return gp[0], nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:47,代码来源:buildquery.go


示例19: main

func main() {
	var bindaddr = flag.String("bindaddr", "0.0.0.0:7245", "bind address")
	rand.Seed(time.Now().UnixNano())
	flag.Parse()
	flagenv.Prefix = "ALKASIR_WANIP_SERVER_"
	flagenv.Parse()
	lg.CopyStandardLogTo("INFO")
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		ipAddress, _, _ := net.SplitHostPort(r.RemoteAddr)
		fmt.Fprintf(w, "%s", ipAddress)
		if lg.V(5) {
			lg.Infof("returning %s", ipAddress)
		}
	})
	lg.Infof("Listening to http://%s", *bindaddr)
	err := http.ListenAndServe(*bindaddr, nil)
	if err != nil {
		lg.Fatal(err)
	}
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:20,代码来源:alkasir-wanip-server.go


示例20: parseConfig

// SetConfig reads configuration from json byte stream
func parseConfig(config []byte) (*Settings, error) {
	s := &Settings{}
	err := json.Unmarshal(config, &s)
	if err != nil {
		return nil, err
	}

	for i, c := range s.Connections {
		err := c.EnsureID()
		if err != nil {
			lg.Fatal(err)
		}
		lg.V(15).Infof("connection    id: %s", c.ID)
		if lg.V(50) {
			v, _ := c.Encode()
			lg.Infof("connection encoded: %s", v)
			lg.Infof("connection    full: %+v", c)
		}
		s.Connections[i] = c
	}
	return s, nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:23,代码来源:config.go



注:本文中的github.com/thomasf/lg.Fatal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang lg.Infof函数代码示例发布时间:2022-05-28
下一篇:
Golang lg.Errorln函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap