Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

30
vendor/github.com/go-vgo/gt/conf/BUILD.bazel generated vendored Normal file
View File

@@ -0,0 +1,30 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"conf.go",
"go-toml.go",
],
importmap = "go-common/vendor/github.com/go-vgo/gt/conf",
importpath = "github.com/go-vgo/gt/conf",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/fsnotify/fsnotify:go_default_library",
"//vendor/github.com/pelletier/go-toml:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

65
vendor/github.com/go-vgo/gt/conf/conf.go generated vendored Normal file
View File

@@ -0,0 +1,65 @@
// Copyright 2017 The go-vgo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// https://github.com/go-vgo/gt/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
package conf
import (
"log"
"sync"
// "time"
"github.com/fsnotify/fsnotify"
)
var (
// config Config
confLock = new(sync.RWMutex)
)
// NewWatcher new fsnotify watcher
func NewWatcher(paths string, config interface{}) {
Watch(paths, config)
}
// Watch new fsnotify watcher
func Watch(paths string, config interface{}) {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal("fsnotify.NewWatcher(): ", err)
}
defer watcher.Close()
done := make(chan bool)
go func() {
for {
select {
case event := <-watcher.Events:
log.Println("watcher events: ", event)
// if event.Op&fsnotify.Chmod == fsnotify.Chmod {
// log.Println("watcher.Events: ignore CHMOD event: ", event)
// continue
// }
if event.Op&fsnotify.Write == fsnotify.Write {
// log.Println("modified file: ", event.Name)
Init(paths, config)
log.Println("watch config: ", config)
}
case err := <-watcher.Errors:
log.Println("watcher.Errors error: ", err)
}
}
}()
err = watcher.Add(paths)
if err != nil {
log.Fatal("watcher.Add: ", err)
}
<-done
}

31
vendor/github.com/go-vgo/gt/conf/go-toml.go generated vendored Normal file
View File

@@ -0,0 +1,31 @@
// Copyright 2017 The go-vgo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// https://github.com/go-vgo/gt/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// +build !toml
package conf
import (
"io/ioutil"
"log"
"github.com/pelletier/go-toml"
)
// Init toml config
func Init(filePath string, config interface{}) {
confLock.Lock()
fileBytes, err := ioutil.ReadFile(filePath)
if err != nil {
log.Fatal("ioutil.ReadFile error: ", err)
}
toml.Unmarshal(fileBytes, config)
confLock.Unlock()
}

29
vendor/github.com/go-vgo/gt/conf/toml.go generated vendored Normal file
View File

@@ -0,0 +1,29 @@
// Copyright 2017 The go-vgo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// https://github.com/go-vgo/gt/blob/master/LICENSE
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// +build toml
package conf
import (
"log"
"github.com/BurntSushi/toml"
)
// Init toml config
func Init(fliePath string, config interface{}) {
confLock.Lock()
if _, err := toml.DecodeFile(filePath, config); err != nil {
log.Println("toml.DecodeFile error: ", err)
return
}
confLock.Unlock()
}