本文整理汇总了Golang中github.com/thomasf/lg.Infoln函数的典型用法代码示例。如果您正苦于以下问题:Golang Infoln函数的具体用法?Golang Infoln怎么用?Golang Infoln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infoln函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: exit
func exit() {
lg.Infoln("alkasir is shutting down")
atexitMu.Lock() // this lock should be kept, one shutdown should be enough for everyone.
lg.Flush()
if err := clientconfig.Write(); err != nil {
lg.Errorf("could not save config file: %s", err.Error())
}
lg.V(9).Infoln("running atexit funcs")
for _, f := range atexitFuncs {
funcName := runtime.FuncForPC(reflect.ValueOf(f).Pointer()).Name()
lg.V(10).Infoln("Running at exit func", funcName)
f()
lg.V(10).Infoln("Finished at exit func", funcName)
}
atexitFuncs = atexitFuncs[:0]
lg.V(9).Infoln("atexit funcs done")
lg.V(9).Infoln("stopping connectionmanager")
service.StopConnectionManager()
lg.V(9).Infoln("stopping services")
service.StopAll()
lg.V(9).Infoln("services stopped")
lg.V(9).Infoln("waiting for UI shutdown to finish")
uiRunning.Wait()
lg.V(9).Infoln("ui shut down")
lg.Flush()
lg.Infoln("alkasir shutdown complete")
lg.Flush()
time.Sleep(time.Millisecond * 1)
os.Exit(0)
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:31,代码来源:client.go
示例2: upgradeBinaryCheck
func upgradeBinaryCheck(diffsBaseURL string) error {
artifactNameMu.Lock()
artifact := artifactName
artifactNameMu.Unlock()
cl, err := NewRestClient()
if err != nil {
return err
}
res, found, err := cl.CheckBinaryUpgrade(shared.BinaryUpgradeRequest{
Artifact: artifact,
FromVersion: VERSION,
})
if err != nil {
return err
}
if !found {
lg.Infoln("no update found")
return nil
}
lg.Warningf("found update %+v", res)
httpclient, err := service.NewTransportHTTPClient(2 * time.Hour)
if err != nil {
return err
}
opts, err := upgradebin.NewUpdaterOptions(res, shared.UpgradeVerificationPublicKey)
if err != nil {
return err
}
u, err := url.Parse(diffsBaseURL)
if err != nil {
lg.Errorln(err)
return err
}
u.Path = path.Join(u.Path, artifact, VERSION, res.Version)
URL := u.String()
lg.Infoln("downloading", URL)
resp, err := httpclient.Get(URL)
if err != nil {
lg.Errorln(err)
return err
}
defer resp.Body.Close()
err = upgradebin.Apply(resp.Body, opts)
if err != nil {
lg.Errorln(err)
// will be retried the next time the client starts
return nil
}
return nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:59,代码来源:upgradebin.go
示例3: Language
func (w *WMGUI) Language(lang string) error {
w.langMu.Lock()
defer w.langMu.Unlock()
T, err := i18n.Tfunc(lang)
if err != nil {
return err
}
quitMsg := T("quit_alkasir")
helpMsg := T("action_help")
copyMsg := T("copy_browser_code_to_clipboard")
openMsg := T("open_in_browser")
if !w.langSet {
w.open = systray.AddMenuItem(openMsg, openMsg)
w.help = systray.AddMenuItem(helpMsg, helpMsg)
w.copy = systray.AddMenuItem(copyMsg, copyMsg)
w.quit = systray.AddMenuItem(quitMsg, quitMsg)
w.langSet = true
go func() {
for {
select {
case <-w.quit.ClickedCh:
lg.Infoln("quit clicked")
go func() {
ui.Actions.Quit <- true
}()
case <-w.copy.ClickedCh:
go func() {
lg.Infoln("copy to clipboard clicked")
ui.Actions.CopyBrowserCodeToClipboard <- true
}()
case <-w.help.ClickedCh:
go func() {
lg.Infoln("help clicked")
ui.Actions.Help <- true
}()
case <-w.open.ClickedCh:
go func() {
lg.Infoln("open browser clicked")
ui.Actions.OpenInBrowser <- true
}()
}
}
}()
return nil
}
w.quit.SetTitle(quitMsg)
w.quit.SetTooltip(quitMsg)
w.help.SetTitle(helpMsg)
w.help.SetTooltip(helpMsg)
w.copy.SetTitle(copyMsg)
w.copy.SetTooltip(copyMsg)
w.open.SetTitle(openMsg)
w.open.SetTooltip(openMsg)
return nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:56,代码来源:wm.go
示例4: upgradeBinaryCheck
func upgradeBinaryCheck() error {
if !upgradeEnabled {
lg.Infoln("binary upgrades are disabled using the command line flag")
return nil
}
artifactNameMu.Lock()
artifact := artifactName
artifactNameMu.Unlock()
cl, err := NewRestClient()
if err != nil {
return err
}
// TODO: check for current artifact + version (need to add artifact id to cmd's)
res, found, err := cl.CheckBinaryUpgrade(shared.BinaryUpgradeRequest{
Artifact: artifact,
FromVersion: VERSION,
})
if err != nil {
return err
}
if !found {
lg.Infoln("no update found")
return nil
}
lg.Warningf("found update %+v", res)
httpclient, err := service.NewTransportHTTPClient()
if err != nil {
return err
}
opts, err := upgradebin.NewUpdaterOptions(res, shared.UpgradeVerificationPublicKey)
if err != nil {
return err
}
URL := fmt.Sprintf("https://central.server.domain/u/%s/%s/%s", artifact, VERSION, res.Version)
lg.Infoln("downloading %s", URL)
resp, err := httpclient.Get(URL)
if err != nil {
lg.Errorln(err)
return err
}
defer resp.Body.Close()
err = upgradebin.Apply(resp.Body, opts)
if err != nil {
lg.Errorln(err)
// will be retried the next time the client starts
return nil
}
return nil
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:56,代码来源:upgradebin.go
示例5: UpgradeConfig
// UpgradeConfig updates the config, if needed.
func UpgradeConfig() (bool, error) {
currentConrfigMu.Lock()
defer currentConrfigMu.Unlock()
if !currentConfig.configRead {
return false, errors.New("config not read")
}
prevVer := currentConfig.Settings.Version
switch currentConfig.Settings.Version {
case 0: // when config file was created from template
currentConfig.Settings.Version = 1
fallthrough
case 1:
lg.Infoln("updating configuration to v1")
m := &modifyConnections{
Connections: currentConfig.Settings.Connections,
Add: []string{
"aieyJ0Ijoib2JmczQiLCJzIjoiXCJjZXJ0PUdzVFAxVmNwcjBJeE9aUkNnUHZ0Z1JsZVJWQzFTRmpYWVhxSDVvSEhYVFJ4M25QVnZXN2xHK2RkREhKWmw4YjBOVFZ1VGc7aWF0LW1vZGU9MFwiIiwiYSI6IjEzOS4xNjIuMjIxLjEyMzo0NDMifQ==",
"aieyJ0Ijoib2JmczQiLCJzIjoiXCJjZXJ0PTMzdXNkSUVDemFyRUpsWFpQM0w0Y2x0bi9vNXdhVUlOcHRUU0JSYk5BQVpVcVlsajhiZm5MWGYyb3BFNHE2c0NlYzY3Ync7aWF0LW1vZGU9MFwiIiwiYSI6IjQ2LjIxLjEwMi4xMDk6NDQzIn0=",
},
Remove: []string{
// NOTE: old hash function used, not a current format ID
"xFa9T1i6bJMJIvK6kxFA1xvQGfW58BY3OLkrPXbpvAY=",
},
}
currentConfig.Settings.Connections = m.Update()
currentConfig.Settings.Version = 2
fallthrough
case 2:
m := &modifyConnections{
Connections: currentConfig.Settings.Connections,
Protect: []string{
"z0VZS-Kx9tMfoBEyX6br19GaJgKDe0IK0i6JKyhKp2s",
"ipJ2oW8xr9TFDvfU92qGvDaPwZttf_GSjGZ4KW7inBI",
},
Remove: []string{
"Ul3D2G1dI3_Z4sLXQ9IUQdIFH4pSDyNjTwf_auy93Os",
},
}
currentConfig.Settings.Connections = m.Update()
currentConfig.Settings.Version = 3
fallthrough
case 3:
key := browsercode.NewKey()
currentConfig.Settings.Local.ClientAuthKey = key
currentConfig.Settings.Local.ClientBindAddr = "127.0.0.1:8899"
currentConfig.Settings.Version = 4
fallthrough
case 4:
lg.Infoln("Settings version", currentConfig.Settings.Version)
default:
lg.Errorln("Future configuration version!", currentConfig.Settings.Version)
}
return currentConfig.Settings.Version != prevVer, nil
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:56,代码来源:updates.go
示例6: Read
func Read(bank int) ([]omron.Entry, error) {
var entries []omron.Entry
const (
config = 0x1
iface = 0x0
setup = 0x0
endpointOut = 2
endpointIn = 0x81
)
epOut, err := usbdevice.OpenEndpoint(config, iface, setup, endpointOut|uint8(usb.ENDPOINT_DIR_OUT))
// dev, err := usbdevice.Open()
if err != nil {
return entries, err
}
epIn, err := usbdevice.OpenEndpoint(config, iface, setup, endpointIn|uint8(usb.ENDPOINT_DIR_IN))
if err != nil {
return entries, err
}
n, err := epOut.Write(cmdInit)
if err != nil {
return entries, err
}
lg.Infoln("wrote", n, "bytes")
// dev.Configs()
var readBytes []byte
n, err = epIn.Read(readBytes)
if err != nil {
return entries, err
}
lg.Infoln("read", n, "bytes")
os.Exit(1)
addr := (0x02AC)
for i := 0; i < 70; i++ {
// if (abort) {}
cmdData[4] = byte(addr >> 8)
cmdData[5] = byte(addr & 0xFF)
}
os.Exit(1)
return entries, nil
}
开发者ID:thomasf,项目名称:bpchart,代码行数:48,代码来源:readgo.go
示例7: getVersion
func (b *BuildQuery) getVersion() (*Artifact, error) {
lg.Infof("Getting versions of %s", b.ArtifactDisplayName())
c, err := getNexusClient()
if err != nil {
return nil, err
}
artifacts, err := c.Artifacts(
search.InRepository{
RepositoryID: repoID,
Criteria: search.ByCoordinates{
GroupID: "com.alkasir",
Version: b.Version,
ArtifactID: b.Cmd,
Classifier: b.Classifier(),
},
},
)
if err != nil {
return nil, err
}
if len(artifacts) != 1 {
lg.Infoln(artifacts)
return nil, errors.New("one match expected")
}
return &Artifact{Artifact: artifacts[0]}, nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:27,代码来源:buildquery.go
示例8: getMasterSnapshot
func (b *BuildQuery) getMasterSnapshot(repoID string) (*Artifact, error) {
c, err := getNexusClient()
if err != nil {
return nil, err
}
artifacts, err := c.Artifacts(
search.InRepository{
RepositoryID: repoID,
Criteria: search.ByCoordinates{
GroupID: "com.alkasir",
Version: "SNAPSHOT",
ArtifactID: b.Cmd,
Classifier: b.Classifier(),
},
},
)
if err != nil {
return nil, err
}
if len(artifacts) != 1 {
lg.Infoln(artifacts)
return nil, fmt.Errorf("found more than one result: %v", artifacts)
}
return &Artifact{Artifact: artifacts[0]}, nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:26,代码来源:buildquery.go
示例9: GenPAC
// GenPAC regenerates the proxy auto configration file file
func GenPAC() []byte {
buf := new(bytes.Buffer)
direct := getDirectList()
blocked := getBlockedList()
data := struct {
BlockedMethod string
DirectDomains string
BlockedDomains string
TopLevel string
DefaultMethod string
}{
pac.blockedMethod,
direct,
blocked,
pac.topLevelDomain,
pac.defaultMethod,
}
if err := pac.template.Execute(buf, data); err != nil {
lg.Infoln("Error generating pac file:", err)
panic("Error generating pac file")
}
return buf.Bytes()
}
开发者ID:thomasf,项目名称:alkasir,代码行数:27,代码来源:pac.go
示例10: TestServiceClientFail
func TestServiceClientFail(t *testing.T) {
if os.Getenv("ALKASIR_SERVICE") == "transport" {
failToStart = false
server.AddChecker(MockTransportCheck)
if !server.CheckServiceEnv() {
lg.Infoln("error no support")
}
server.RunService()
return
}
service.UpdateConnections(testConnections)
service.UpdateTransports(testTransports)
service.Arg = "-test.run=TestServiceClientFail"
connection := shared.Connection{
Transport: "socks5",
}
connection1Proxy, err := service.NewTransportService(connection)
if err != nil {
t.Fatalf("could not start %v", err)
}
err = connection1Proxy.Start()
if err != nil {
panic(err)
}
if err != nil {
t.Fatalf("process ran with err %v, want exit status 0", err)
}
}
开发者ID:thomasf,项目名称:alkasir,代码行数:31,代码来源:service_test.go
示例11: LinkBinaries
// LinkBinaries links any binaries from an extracted archive path to PWD.
func (a *Artifact) LinkBinaries() error {
bins := a.Binaries()
for _, file := range bins {
basename := filepath.Base(file)
lg.Infoln(file, basename)
os.Remove(basename)
os.Symlink(file, basename)
}
return nil
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:11,代码来源:artifact.go
示例12: Read
// ReadConfig read all app settings from available config files and/or defalts.
func Read() (*Config, error) {
err := readSettings(currentConfig)
if err != nil {
return nil, err
}
err = readHostFiles(currentConfig)
if err != nil {
lg.Infoln("could not read host lists..")
}
currentConfig.configRead = true
return currentConfig, nil
}
开发者ID:thomasf,项目名称:alkasir,代码行数:13,代码来源:config.go
示例13: Run
func (a *Artifact) Run(cmdglob string) error {
files, err := a.GlobPath(cmdglob)
if err != nil {
return err
}
if len(files) != 1 {
lg.Infoln("wrong number of results for glob", files)
os.Exit(1)
}
cmd := exec.Command(files[0], os.Args[2:]...)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
return cmd.Run()
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:14,代码来源:artifact.go
示例14: Method
func (s *Services) Method(id string) *Method {
if strings.TrimSpace(id) == "" {
lg.Infoln("trying to fetch method by illegal key")
return nil
}
var method *Method
allMethods := s.AllMethods()
for _, m := range allMethods {
if m.ID == id {
method = &Method{}
*method = *m
}
}
return method
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:15,代码来源:misc.go
示例15: OpenDB
// InitDBopens a connection to the database.
func OpenDB() error {
var err error
sqlDB, err = db.Open(pgConnFlag)
if err != nil {
return err
}
if err := sqlDB.Ping(); err != nil {
sqlDB.Close()
sqlDB = nil
return err
}
lg.Infoln("Successfully connected to the database")
return nil
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:16,代码来源:alkasir-admin.go
示例16: InitDB
// InitDB opens a connection to the database.
func InitDB() error {
var err error
sqlDB, err = Open(*pgConnString)
if err != nil {
return err
}
if err := sqlDB.Ping(); err != nil {
sqlDB.Close()
sqlDB = nil
return err
}
sqlDB.SetMaxIdleConns(100)
lg.Infoln("Successfully connected to the database")
return nil
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:17,代码来源:postgres_test.go
示例17: commandHandler
// simple loop for commands / subcommands
func commandHandler(args []string) error {
if len(args) < 1 {
printHelp()
os.Exit(1)
}
lg.Infoln(args)
var trail []string
node := rootCommand
var findCmd string
for {
if len(args) < 1 {
fmt.Println("")
fmt.Printf("command '%s' not found in '%s'\n",
findCmd, strings.Join(trail, " "))
return errCommandNotFound
}
findCmd = args[0]
trail = append(trail, findCmd)
c, ok := node.Get(findCmd)
if !ok {
fmt.Println("")
fmt.Printf("command '%s' not found in '%s'\n",
findCmd, strings.Join(trail, " "))
return errCommandNotFound
}
newArgs := args[1:]
if c.Func != nil {
err := c.Func(newArgs)
if err != nil {
switch err {
case errNoValue:
fmt.Println("")
fmt.Printf("command '%s' requires additional arguments\n",
strings.Join(trail, " "))
return nil
}
fmt.Printf("error running cmd %v %v", trail, newArgs)
return err
}
return nil
}
node = c
args = newArgs
}
}
开发者ID:gitter-badger,项目名称:alkasir,代码行数:46,代码来源:alkasir-admin.go
示例18: TestServerFail
func TestServerFail(t *testing.T) {
if os.Getenv("__TEST_SUBCMD") == "1" {
server.AddChecker(MockTransportCheck)
failToStart = true
if !server.CheckServiceEnv() {
lg.Infoln("error no support")
}
server.RunService()
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestServerFail")
env := append(os.Environ(), "__TEST_SUBCMD=1")
cmd.Env = env
// cmd.Stdout = os.Stdout
err := cmd.Run()
if e, ok := err.(*exec.ExitError); ok && !e.Success() {
return
}
t.Fatalf("process ran with err %v, want exit status 1", err)
}
开发者ID:thomasf,项目名称:alkasir,代码行数:20,代码来源:service_test.go
示例19: TestServerSuccess
func TestServerSuccess(t *testing.T) {
if os.Getenv("__TEST_SUBCMD") == "1" {
failToStart = false
server.AddChecker(MockTransportCheck)
if !server.CheckServiceEnv() {
lg.Infoln("error no support")
}
server.RunService()
return
}
cmd := exec.Command(os.Args[0], "-test.run=TestServerSuccess")
env := append(os.Environ(), "__TEST_SUBCMD=1")
env = append(env, "ALKASIR_SERVICE=transport")
env = append(env, "ALKASIR_TRANSPORT=socks5")
cmd.Env = env
// cmd.Stdout = os.Stdout
err := cmd.Run()
if err != nil {
t.Fatalf("process ran with err %v, want exit status 0", err)
}
}
开发者ID:thomasf,项目名称:alkasir,代码行数:21,代码来源:service_test.go
示例20: StartBinaryUpgradeChecker
// StartBinaryUpgradeChecker checks for binary upgrades when the connection is
// up and on a schedule.
//
// This function runs in it's own goroutine.
func StartBinaryUpgradeChecker(diffsBaseURL string) {
if !upgradeEnabled {
lg.Infoln("binary upgrades are disabled using the command line flag")
return
}
if VERSION == "" {
lg.Warningln("VERSION not set, binary upgrades are disabled")
return
}
_, err := version.NewVersion(VERSION)
if err != nil {
lg.Warningf("VERSION '%s' is not a valid semver version, binary upgrades are disabled: %v", VERSION, err)
return
}
connectionEventListener := make(chan service.ConnectionHistory)
uChecker, _ := NewUpdateChecker("binary")
service.AddListener(connectionEventListener)
for {
select {
// Update when the transport connection comes up
case event := <-connectionEventListener:
if event.IsUp() {
uChecker.Activate()
uChecker.UpdateNow()
}
// Update by request of the update checker
case request := <-uChecker.RequestC:
err := upgradeBinaryCheck(diffsBaseURL)
if err != nil {
lg.Errorln(err)
request.ResponseC <- UpdateError
} else {
request.ResponseC <- UpdateSuccess
}
}
}
}
开发者ID:thomasf,项目名称:alkasir,代码行数:43,代码来源:upgradebin.go
注:本文中的github.com/thomasf/lg.Infoln函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论