本文整理汇总了Golang中github.com/vharitonsky/iniflags.Parse函数的典型用法代码示例。如果您正苦于以下问题:Golang Parse函数的具体用法?Golang Parse怎么用?Golang Parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Parse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
iniflags.Parse()
runtime.GOMAXPROCS(*goMaxProcs)
cache = createCache()
defer cache.Close()
upstreamClient = http.Client{
Transport: &http.Transport{
MaxIdleConnsPerHost: *maxIdleUpstreamConns,
},
}
var addr string
for _, addr = range strings.Split(*httpsListenAddrs, ",") {
go serveHttps(addr)
}
for _, addr = range strings.Split(*listenAddrs, ",") {
go serveHttp(addr)
}
waitForeverCh := make(chan int)
<-waitForeverCh
}
开发者ID:kangkot,项目名称:ybc,代码行数:25,代码来源:main.go
示例2: main
func main() {
flag.IntVar(&port, "port", 8080, "the port listen to")
flag.StringVar(&serverName, "server_name", "", "the server name")
flag.Var(&hosts, "server", "the server connect to")
flag.StringVar(&docroot, "docroot", ".", "the local http www root")
iniflags.Parse()
initRouters()
if len(hosts) == 0 {
log.Fatal("you must special a server")
}
http2.VerboseLogs = false
log.Printf("Listening on :%d", port)
p := &proxy{}
p.handler = &http2.Transport{
DialTLS: p.dialTLS,
AllowHTTP: true,
}
hdr := &myhandler{proxy: p}
err := http.ListenAndServe(fmt.Sprintf(":%d", port),
handlers.CombinedLoggingHandler(os.Stdout, hdr))
if err != nil {
log.Fatal(err)
}
}
开发者ID:fangdingjun,项目名称:gpp,代码行数:28,代码来源:local.go
示例3: LoadConfig
func LoadConfig() Config {
var (
mongo_user = flag.String("mongo_user", "", "MongoDB User")
mongo_pass = flag.String("mongo_pass", "", "MongoDB Password")
statsd_host = flag.String("statsd_host", "localhost", "StatsD Host")
statsd_port = flag.Int("statsd_port", 8125, "StatsD Port")
statsd_env = flag.String("statsd_env", "dev", "StatsD metric environment prefix")
statsd_cluster = flag.String("statsd_cluster", "0", "StatsD metric cluster prefix")
interval = flag.Duration("interval", 5*time.Second, "Polling interval")
)
flag.Var(&mongo_addresses, "mongo_address", "List of mongo addresses in host:port format")
iniflags.Parse()
if len(mongo_addresses) == 0 {
mongo_addresses = append(mongo_addresses, "localhost:27017")
}
cfg := Config{
Interval: *interval,
Mongo: Mongo{
Addresses: mongo_addresses,
User: *mongo_user,
Pass: *mongo_pass,
},
Statsd: Statsd{
Host: *statsd_host,
Port: *statsd_port,
Env: *statsd_env,
Cluster: *statsd_cluster,
},
}
return cfg
}
开发者ID:nod,项目名称:mgo-statsd,代码行数:33,代码来源:config.go
示例4: parse_flags
func parse_flags() {
iniflags.Parse()
var err error
for _, s := range srv {
sv, err := parse_server(s)
if err != nil {
log.Print(err)
} else {
Servers = append(Servers, sv)
}
}
for _, dsvr := range default_server {
proto, addr, err := parse_addr(dsvr)
if err != nil {
log.Fatal(err)
}
var c *dns.Client
if proto == "udp" {
c = client_udp
} else {
c = client_tcp
}
upsrv := &UpstreamServer{
Addr: addr,
Proto: proto,
client: c,
}
DefaultServer = append(DefaultServer, upsrv)
}
if len(DefaultServer) == 0 {
log.Fatal("please special a -upstream")
}
a, err := load_domain(blacklist_file)
if err != nil {
log.Println(err)
} else {
Blacklist_ips = a
}
if hostfile == "" {
hostfile = GetHost()
}
if hostfile != "" {
record_hosts, err = ReadHosts(hostfile)
if err != nil {
log.Fatal(err)
}
}
if region_file != "" {
ip_region = parse_net(region_file)
}
}
开发者ID:fangdingjun,项目名称:gdns,代码行数:60,代码来源:arguments.go
示例5: main
func main() {
iniflags.Parse()
backend1 := logging.NewLogBackend(os.Stdout, "", 0)
backend1Formatter := logging.NewBackendFormatter(backend1, format)
logging.SetBackend(backend1Formatter)
//Expand path
path := *p
if strings.HasPrefix(*p, "~") {
usr, _ := user.Current()
dir := usr.HomeDir
path = strings.Replace(*p, "~", dir, 1)
}
//Run each scraper
_log.Info("basepath: [%s], scrapers: [%s]", path, *scrapers)
for _, s := range strings.Split(*scrapers, ",") {
switch s {
case "bitstamp":
handler_wrapper(path, bitstamp.Scrape, "bitstamp")
case "bitfinex":
handler_wrapper(path, bitfinex.Scrape, "bitfinex")
}
}
}
开发者ID:cryptobase,项目名称:crypto-scraper,代码行数:26,代码来源:main.go
示例6: init
func init() {
flags()
iniflags.Parse()
session, err := mgo.Dial(mongoCS)
if err != nil {
panic(err)
}
session.SetMode(mgo.Monotonic, true)
MongoDB = session.DB(mongoName)
}
开发者ID:Nainterceptor,项目名称:MiniProject-Ping,代码行数:10,代码来源:config.go
示例7: main
func main() {
// set up recovery
defer recoverPanic()
// intialize flags
iniflags.Parse()
// start web server
server()
}
开发者ID:seanhagen,项目名称:car-gasoline-tracker,代码行数:10,代码来源:main.go
示例8: main
func main() {
iniflags.Parse()
fmt.Printf("Config:\n")
flag.VisitAll(func(f *flag.Flag) {
fmt.Printf("%s=%v\n", f.Name, f.Value)
})
fmt.Printf("\n")
rand.Seed(time.Now().UnixNano())
runtime.GOMAXPROCS(*goMaxProcs)
serverAddrs_ := strings.Split(*serverAddrs, ",")
fmt.Printf("Preparing...")
key = getRandomKey(*keySize)
value = getRandomValue(*valueSize)
stats := make([]Stats, *workersCount)
for i := 0; i < *workersCount; i++ {
stats[i].responseTimeHistogram = make([]uint32, *responseTimeHistogramSize)
stats[i].minResponseTime = time.Hour * 24 * 365
}
var startTime time.Time
defer printStats(stats, &startTime)
var worker func(wg *sync.WaitGroup, ch chan int, stats *Stats)
switch *clientType {
case "original":
worker = getWorkerOrg(serverAddrs_)
case "new":
worker = getWorkerNew(serverAddrs_)
default:
log.Fatalf("Unknown clientType=[%s]. Expected 'new' or 'original'", *clientType)
}
fmt.Printf("done\n")
fmt.Printf("starting...")
startTime = time.Now()
ch := make(chan int, 1000000)
var wg sync.WaitGroup
defer wg.Wait()
for i := 0; i < *workersCount; i++ {
wg.Add(1)
go worker(&wg, ch, &stats[i])
}
for i := 0; i < *requestsCount; i++ {
ch <- i
}
close(ch)
}
开发者ID:jjoergensen,项目名称:ybc,代码行数:53,代码来源:main.go
示例9: main
func main() {
iniflags.Parse()
api := slack.New(*token)
//var channel_id string
channel_id := getChannelId(*channel, api)
var include, exclude *regexp.Regexp
var err error
if *includes != "" {
include, err = regexp.Compile(*includes)
if err != nil {
fmt.Println("ERROR: Failed to compile `line_includes` regex.")
fmt.Println(err)
api.PostMessage(channel_id, "==> slackd failed to compile `line_includes` regex.", slack.NewPostMessageParameters())
api.PostMessage(channel_id, err.Error(), slack.NewPostMessageParameters())
os.Exit(2)
}
}
if *excludes != "" {
exclude, err = regexp.Compile(*excludes)
if err != nil {
fmt.Println("ERROR: Failed to compile `line_excludes` regex.")
fmt.Println(err)
api.PostMessage(channel_id, "==> slackd failed to compile `line_excludes` regex.", slack.NewPostMessageParameters())
api.PostMessage(channel_id, err.Error(), slack.NewPostMessageParameters())
os.Exit(2)
}
}
log, err := tail.TailFile(*file, tail.Config{Follow: true, ReOpen: *reopen, Poll: true})
if err != nil {
fmt.Println("ERROR: Could not tail the specified log.")
fmt.Println(err)
api.PostMessage(channel_id, "==> slackd could not tail the specified log.", slack.NewPostMessageParameters())
api.PostMessage(channel_id, err.Error(), slack.NewPostMessageParameters())
os.Exit(2)
}
for line := range log.Lines {
if (include != nil && include.MatchString(line.Text)) || (exclude != nil && !exclude.MatchString(line.Text)) {
api.PostMessage(
channel_id,
fmt.Sprintf("```%s```", line.Text),
slack.NewPostMessageParameters())
}
}
}
开发者ID:swill,项目名称:slackd,代码行数:48,代码来源:slackd.go
示例10: main
func main() {
iniflags.Parse()
if *showVersion {
fmt.Println(Commit)
return
}
DB, err = sql.Open(
"mysql",
fmt.Sprintf("%s:%[email protected](%s:%s)/mysql", *sqlUser, *sqlPass, *sqlHost, *sqlPort),
)
if err != nil {
log.Fatal(err)
}
http.HandleFunc("/", statusHandler)
http.ListenAndServe(*httpHost+":"+*httpPort, nil)
}
开发者ID:hendrikb,项目名称:galera_watchdog,代码行数:16,代码来源:watchdog.go
示例11: main
func main() {
iniflags.Parse()
unixTime = uint64(time.Now().Unix())
initPow()
go regenPowChallenges()
go updateTime()
loadHtmlFile()
var addr string
for _, addr = range strings.Split(*listenAddrs, ",") {
go serveHttp(addr)
}
waitForeverCh := make(chan int)
<-waitForeverCh
}
开发者ID:Freeaqingme,项目名称:Webjobber,代码行数:17,代码来源:main.go
示例12: main
func main() {
flag.Set("allowUnknownFlags", "true")
iniflags.Parse()
if certPath == nil || len(*certPath) == 0 {
fmt.Fprintln(os.Stderr, "You must specify a Certificate Path")
os.Exit(1)
return
}
certFolderDB, err := utils.NewFolderDatabase(*certPath, 0444, *certsPerFolder)
if err != nil {
fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to open Certificate Path: %s: %s", certPath, err))
os.Exit(1)
return
}
if flag.NArg() < 1 {
fmt.Fprintln(os.Stderr, "Must specify the certificate ID to retrieve")
os.Exit(1)
return
}
id, err := strconv.ParseUint(flag.Arg(0), 10, 64)
if err != nil {
fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to parse as integer: %s", err))
os.Exit(1)
return
}
data, err := certFolderDB.Get(id)
if err != nil {
fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to find CertID: %s", err))
os.Exit(1)
return
}
_, err = os.Stdout.Write(data)
if err != nil {
fmt.Fprintln(os.Stderr, fmt.Sprintf("unable to write out CertID: %s", err))
os.Exit(1)
return
}
}
开发者ID:jcjones,项目名称:ct-sql,代码行数:45,代码来源:get-cert.go
示例13: main
func main() {
// Parse any set command line flags
iniflags.Parse()
config := &Config{iface: *iface, pcapOut: *pcapOut, enableAF: *enableAF, isRunning: true}
// On ^C or SIGTERM, gracefully stop anything running
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigc
log.Print("Received sigterm/sigint, stopping")
config.isRunning = false
}()
// Open pcap log output
if err := openPcap(config); err != nil {
log.Fatal("Error opening pcap file: ", err)
}
defer config.pcapFile.Close()
// Listen on the interface
var sniffer Sniffer
if config.enableAF {
sniffer = &PcapSniffer{}
log.Print("Using afpacket to sniff packets")
} else {
sniffer = &AfpacketSniffer{}
log.Print("Using libpcap to sniff packets")
}
if err := sniffer.Open(config); err != nil {
log.Fatal("Failed to open the sniffer: ", err)
}
config.sniffer = sniffer
defer config.sniffer.Close()
log.Printf("Listening on %s\n", config.iface)
if err := Listen(config); err != nil {
log.Fatal("Listening stopped with an error: ", err)
}
log.Print("Successful exit")
}
开发者ID:postfix,项目名称:sniffer,代码行数:44,代码来源:main.go
示例14: main
func main() {
iniflags.Parse()
flag.VisitAll(func(f *flag.Flag) {
fmt.Printf("%s=%v\n", f.Name, f.Value)
})
runtime.GOMAXPROCS(*goMaxProcs)
testUri, err := url.Parse(*testUrl)
if err != nil {
log.Fatalf("Error=[%s] when parsing testUrl=[%s]\n", err, *testUrl)
}
ch := make(chan int, 100000)
bytesRead := make([]int64, *workersCount)
wg := &sync.WaitGroup{}
for i := 0; i < *workersCount; i++ {
wg.Add(1)
go worker(ch, wg, testUri, &bytesRead[i])
}
log.Printf("Test started\n")
startTime := time.Now()
for i := 0; i < *requestsCount; i++ {
ch <- 1
}
close(ch)
wg.Wait()
duration := time.Since(startTime)
seconds := float64(duration) / float64(time.Second)
var totalBytesRead int64
for i := 0; i < *workersCount; i++ {
totalBytesRead += bytesRead[i]
}
kbytesRead := float64(totalBytesRead) / float64(1000)
qps := float64(*requestsCount) / seconds
kbps := kbytesRead / seconds
log.Printf("Done\n")
log.Printf("%d requests from %d workers in %s\n", *requestsCount, *workersCount, duration)
log.Printf("%.0f Kbytes read, %.0f qps, %.0f Kbps\n", kbytesRead, qps, kbps)
}
开发者ID:valyala,项目名称:ybc,代码行数:43,代码来源:main.go
示例15: main
func main() {
iniflags.Parse()
// Set up logging
if lw, err := NewLogWatch(); err != nil {
log.Printf("[flag -logfile] '%s' will carry on without the logfile\n", err)
} else {
http.Handle("/tail1000", lw)
}
if config.TrimQueries {
log.Printf("Testing stemming: '%s'\n", StemQuery("I like to stemming my queries"))
// This is a function rather an an init, as it relies of the results of the flags
LoadImportance()
log.Println(TrimQuery("This is a stemming queries that needs a bit of a trim dream babies"))
}
// Create a liveQA
lqa := NewLiveQA()
// Add answer producers
count := 0
for _, name := range config.Producers {
if f, ok := factory[name]; ok {
ap, err := f(name + ".json")
if err != nil {
log.Printf("[Error initialising %s] %s\n", name, err)
} else {
lqa.AddProducer(ap)
log.Printf("Initialised '%s' answer producer\n", name)
count++
}
} else {
log.Printf("[Error initialising %s] Unrecognised answer producer '%s'\n", name, name)
}
}
log.Printf("Initialised %d of %d total answer producers\n", count, len(config.Producers))
http.Handle("/", lqa)
log.Fatal(http.ListenAndServe(":"+strconv.Itoa(config.Port), nil))
}
开发者ID:TimothyJones,项目名称:trec-liveqa-server,代码行数:41,代码来源:main.go
示例16: NewCTConfig
func NewCTConfig() *CTConfig {
ret := &CTConfig{
LogUrl: flag.String("log", "", "URL of the CT Log"),
CensysPath: flag.String("censysJson", "", "Path to a Censys.io certificate json dump"),
CensysUrl: flag.String("censysUrl", "", "URL to a Censys.io certificate json dump"),
CensysStdin: flag.Bool("censysStdin", false, "Read a Censys.io json dump from stdin"),
DbConnect: flag.String("dbConnect", "", "DB Connection String"),
Verbose: flag.Bool("v", false, "verbose output"),
CertPath: flag.String("certPath", "", "Path under which to store full DER-encoded certificates"),
CertsPerFolder: flag.Uint64("certsPerFolder", 16384, "Certificates per folder, when stored"),
Offset: flag.Uint64("offset", 0, "offset from the beginning"),
OffsetByte: flag.Uint64("offsetByte", 0, "byte offset from the beginning, only for censysJson and not compatible with offset"),
Limit: flag.Uint64("limit", 0, "limit processing to this many entries"),
GeoipDbPath: flag.String("geoipDbPath", "", "Path to GeoIP2-City.mmdb"),
NumThreads: flag.Int("numThreads", 1, "Use this many threads per CPU"),
HistoricalDays: flag.Int("histDays", 90, "Update this many days of historical data"),
}
iniflags.Parse()
return ret
}
开发者ID:jcjones,项目名称:ct-sql,代码行数:21,代码来源:config.go
示例17: main
func main() {
var (
httpPort string
globalMux = http.NewServeMux()
)
flag.StringVar(&httpPort, "http.port", "9090", "http listening port")
//load application properties from *.ini file
//Init data access
iniflags.Parse()
globalMux.Handle("/v1/person/", api.BuildAuthRouter())
Logger.Info("Authentication Server listening on port - ", httpPort)
//to handle CORS support
//Angular JS may use OPTION for PUT request , it is handled by CORS
c := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "DELETE", "PUT"},
AllowCredentials: true,
AllowedHeaders: []string{"*"},
})
corsHandler := c.Handler(globalMux)
responseHandler := api.PreJSONProcessor(corsHandler)
//start server
s := &http.Server{
Addr: ":" + httpPort,
Handler: context.ClearHandler(responseHandler),
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
MaxHeaderBytes: 1 << 20,
}
Logger.Fatal(s.ListenAndServe())
}
开发者ID:cfdevops,项目名称:person,代码行数:39,代码来源:main.go
示例18: init
func init() {
iniflags.Parse()
if len(*from) == 0 {
log.Fatal("No From-Email address supplied")
}
if len(*to) == 0 {
log.Fatal("No To-Email address supplied")
}
if len(*pw) == 0 {
log.Println("Warning no password supplied")
}
if len(*user) == 0 {
log.Printf("No username supplied, will use %s instead", *from)
*user = *from
}
if len(*mail_srv) == 0 {
log.Fatal("No mail server address supplied")
}
if strings.Compare(*mail_auth, "CRAMMD5") != 0 && strings.Compare(*mail_auth, "PLAIN") != 0 {
log.Fatal("No valid authentication method for SMTP supplied")
}
}
开发者ID:smotti,项目名称:http-mailer,代码行数:23,代码来源:http-mailer.go
示例19: Init
// init the server with specific name.
func Init(name string) error {
if serverInstance == nil {
// read config
iniflags.Parse()
// read network info
readNetInterfaces()
// log
err := initLog(name, *confLogLevel)
if err != nil {
return err
}
// server instance
serverInstance = &Server{
name: name,
}
// init service manager
serverInstance.svrmgr, err = NewServerManager(name, *confEtcd)
if err != nil {
return err
}
// create RPC client
serverInstance.rpccli, err = NewRPCClient()
if err != nil {
return err
}
Log.Infof("server %s init success.", name)
}
return nil
}
开发者ID:jerry2weng,项目名称:pando-cloud,代码行数:37,代码来源:server.go
示例20: startDaemon
func startDaemon() {
// setupSysTray()
go func() {
// autoextract self
src, _ := osext.Executable()
dest := filepath.Dir(src)
// save the config.ini (if it exists)
if _, err := os.Stat(dest + "/" + *configIni); os.IsNotExist(err) {
fmt.Println("First run, unzipping self")
err := Unzip(src, dest)
fmt.Println("Self extraction, err:", err)
}
if _, err := os.Stat(dest + "/" + *configIni); os.IsNotExist(err) {
flag.Parse()
fmt.Println("No config.ini at", *configIni)
} else {
flag.Set("config", dest+"/"+*configIni)
iniflags.Parse()
}
// setup logging
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
// see if we are supposed to wait 5 seconds
if *isLaunchSelf {
launchSelfLater()
}
var updater = &Updater{
CurrentVersion: version,
ApiURL: *updateUrl,
BinURL: *updateUrl,
DiffURL: "",
Dir: "update/",
CmdName: *appName,
}
if updater != nil {
go updater.BackgroundRun()
}
// data, err := Asset("arduino.zip")
// if err != nil {
// log.Println("arduino tools not found")
// }
createGlobalConfigMap(&globalConfigMap)
//getList()
f := flag.Lookup("addr")
log.Println("Version:" + version)
// hostname
hn, _ := os.Hostname()
if *hostname == "unknown-hostname" {
*hostname = hn
}
log.Println("Hostname:", *hostname)
// turn off garbage collection
// this is dangerous, as u could overflow memory
//if *isGC {
if *gcType == "std" {
log.Println("Garbage collection is on using Standard mode, meaning we just let Golang determine when to garbage collect.")
} else if *gcType == "max" {
log.Println("Garbage collection is on for MAXIMUM real-time collecting on each send/recv from serial port. Higher CPU, but less stopping of the world to garbage collect since it is being done on a constant basis.")
} else {
log.Println("Garbage collection is off. Memory use will grow unbounded. You WILL RUN OUT OF RAM unless you send in the gc command to manually force garbage collection. Lower CPU, but progressive memory footprint.")
debug.SetGCPercent(-1)
}
ip := "0.0.0.0"
log.Print("Starting server and websocket on " + ip + "" + f.Value.String())
//homeTempl = template.Must(template.ParseFiles(filepath.Join(*assets, "home.html")))
log.Println("The Serial Port JSON Server is now running.")
log.Println("If you are using ChiliPeppr, you may go back to it and connect to this server.")
// see if they provided a regex filter
if len(*regExpFilter) > 0 {
log.Printf("You specified a serial port regular expression filter: %v\n", *regExpFilter)
}
// list serial ports
portList, _ := GetList(false)
/*if errSys != nil {
log.Printf("Got system error trying to retrieve serial port list. Err:%v\n", errSys)
log.Fatal("Exiting")
}*/
log.Println("Your serial ports:")
if len(portList) == 0 {
log.Println("\tThere are no serial ports to list.")
}
for _, element := range portList {
log.Printf("\t%v\n", element)
}
//.........这里部分代码省略.........
开发者ID:linkcard,项目名称:serial-port-json-server,代码行数:101,代码来源:main.go
注:本文中的github.com/vharitonsky/iniflags.Parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论