// hello world, the web server
340958
func indexCallback(w http.ResponseWriter, req *http.Request) {
	io.WriteString(w, strings.Replace(html, "${Version}", channel.Version, -1))
}
864601
func Hello(ctx iris.Context) {
	// vars := make(map[string]interface{})
	// vars["message"] = "Hello World!"
	// vars["name"] = ctx.Params().Get("name")
	// [...]
	// &templates.Hello{ Vars: vars }
	// [...]

	// However, as an alternative, we recommend that you should the `ctx.ViewData(key, value)`
	// in order to be able modify the `templates.Hello#Vars` from a middleware(other handlers) as well.
	ctx.ViewData("message", "Hello World!")
	ctx.ViewData("name", ctx.Params().Get("name"))

	// set view data to the `Vars` template's field
	tmpl := &templates.Hello{
		Vars: ctx.GetViewData(),
	}

	// render the template
	ExecuteTemplate(ctx, tmpl)
}
757658
func (w *Server) Start() {
	w.wg.Add(1)
	go func(w *Server) {
		w.server.ListenAndServe()
		w.wg.Done()
	}(w)
}
115926
func Main(listeners ...gumble.EventListener) {
	server := flag.String("server", "localhost:64738", "Mumble server address")
	username := flag.String("username", "gumble-bot", "client username")
	password := flag.String("password", "", "client password")
	insecure := flag.Bool("insecure", false, "skip server certificate verification")
	certificateFile := flag.String("certificate", "", "user certificate file (PEM)")
	keyFile := flag.String("key", "", "user certificate key file (PEM)")

	if !flag.Parsed() {
		flag.Parse()
	}

	host, port, err := net.SplitHostPort(*server)
	if err != nil {
		host = *server
		port = strconv.Itoa(gumble.DefaultPort)
	}

	keepAlive := make(chan bool)

	config := gumble.NewConfig()
	config.Username = *username
	config.Password = *password
	address := net.JoinHostPort(host, port)

	var tlsConfig tls.Config

	if *insecure {
		tlsConfig.InsecureSkipVerify = true
	}
	if *certificateFile != "" {
		if *keyFile == "" {
			keyFile = certificateFile
		}
		if certificate, err := tls.LoadX509KeyPair(*certificateFile, *keyFile); err != nil {
			fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err)
			os.Exit(1)
		} else {
			tlsConfig.Certificates = append(tlsConfig.Certificates, certificate)
		}
	}
	config.Attach(AutoBitrate)
	for _, listener := range listeners {
		config.Attach(listener)
	}
	config.Attach(Listener{
		Disconnect: func(e *gumble.DisconnectEvent) {
			keepAlive <- true
		},
	})
	_, err = gumble.DialWithDialer(new(net.Dialer), address, config, &tlsConfig)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err)
		os.Exit(1)
	}

	<-keepAlive
}
665160
func startWebServer() (codeCh chan string, err error) {
	listener, err := net.Listen("tcp", "localhost:8080")
	if err != nil {
		return nil, err
	}
	codeCh = make(chan string)
	go http.Serve(listener, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		code := r.FormValue("code")
		codeCh <- code // send code to OAuth flow
		listener.Close()
		w.Header().Set("Content-Type", "text/plain")
		fmt.Fprintf(w, "Received code: %v\r\nYou can now safely close this browser window.", code)
	}))
	return codeCh, nil
}
757833
func main() {
	conf, err := GetConfig()
	if err != nil {
		log.Printf("Error getting config [%s]", err)
		os.Exit(1)
	}

	router := mux.NewRouter()

	var database db.DB
	switch conf.DBType {
	case "mem":
		database = db.NewMem()
	case "redis":
		redisOpts := &redis.Options{
			Addr:     fmt.Sprintf(conf.RedisHost),
			Password: conf.RedisPass,
			DB:       conf.RedisDB,
		}
		rawRedisClient := redis.NewClient(redisOpts)
		database = db.NewRedis(rawRedisClient)
	default:
		log.Printf("Error: no available DB type %s", conf.DBType)
		os.Exit(1)
	}

	cah := handlers.NewCreateAppHandler(database)
	cah.RegisterRoute(router)

	gah := handlers.NewGetAppHandler(database)
	gah.RegisterRoute(router)

	dah := handlers.NewDeleteAppHandler(database)
	dah.RegisterRoute(router)

	portStr := fmt.Sprintf(":%d", conf.Port)
	log.Printf("Serving on %s", portStr)
	log.Fatal(http.ListenAndServe(portStr, router))
}
438139
func main() {
	DefaultContainer.Router(CurlyRouter{})
	ws := new(WebService)
	ws.Route(ws.GET("/basepath/{resource:*}").To(staticFromPathParam))
	Add(ws)

	println("[go-restful] serve path tails from http://localhost:8080/basepath")
	log.Fatal(http.ListenAndServe(":8080", nil))
}
790312
func main() {
	// get a bucket and mc.Client connection
	bucket, err := getTestConnection("default")
	if err != nil {
		panic(err)
	}

	// start upr feed
	feed, err := bucket.StartUprFeed("index" /*name*/, 0)
	if err != nil {
		panic(err)
	}

	for i := 0; i < vbcount; i++ {
		err := feed.UprRequestStream(
			uint16(i) /*vbno*/, uint16(0) /*opaque*/, 0 /*flag*/, 0, /*vbuuid*/
			0 /*seqStart*/, 0xFFFFFFFFFFFFFFFF /*seqEnd*/, 0 /*snaps*/, 0)
		if err != nil {
			fmt.Printf("%s", err.Error())
		}
	}

	vbseqNo := receiveMutations(feed, 20000)

	vbList := make([]uint16, 0)
	for i := 0; i < vbcount; i++ {
		vbList = append(vbList, uint16(i))
	}
	failoverlogMap, err := bucket.GetFailoverLogs(vbList)
	if err != nil {
		log.Printf(" error in failover log request %s", err.Error())

	}

	// get a bucket and mc.Client connection
	bucket1, err := getTestConnection("default")
	if err != nil {
		panic(err)
	}

	// add mutations to the bucket
	var mutationCount = 5000
	addKVset(bucket1, mutationCount)

	log.Println("Restarting ....")
	feed, err = bucket.StartUprFeed("index" /*name*/, 0)
	if err != nil {
		panic(err)
	}

	for i := 0; i < vbcount; i++ {
		log.Printf("Vbucket %d High sequence number %d, Snapshot end sequence %d", i, vbseqNo[i][0], vbseqNo[i][1])
		failoverLog := failoverlogMap[uint16(i)]
		err := feed.UprRequestStream(
			uint16(i) /*vbno*/, uint16(0) /*opaque*/, 0, /*flag*/
			failoverLog[0][0],                              /*vbuuid*/
			vbseqNo[i][0] /*seqStart*/, 0xFFFFFFFFFFFFFFFF, /*seqEnd*/
			0 /*snaps*/, vbseqNo[i][1])
		if err != nil {
			fmt.Printf("%s", err.Error())
		}
	}

	var e, f *memcached.UprEvent
	var mutations int
loop:
	for {
		select {
		case f = <-feed.C:
		case <-time.After(time.Second):
			break loop
		}

		if f.Opcode == gomemcached.UPR_MUTATION {
			vbseqNo[f.VBucket][0] = f.Seqno
			e = f
			mutations += 1
		}
	}

	log.Printf(" got %d mutations", mutations)

	exptSeq := vbseqNo[e.VBucket][0] + 1

	if e.Seqno != exptSeq {
		fmt.Printf("Expected seqno %v, received %v", exptSeq+1, e.Seqno)
		//panic(err)
	}
	feed.Close()
}
1172080
func Hello(ctx *cli.Context) command.Command {
	usage := "hello"
	desc := "Returns a greeting"

	return command.NewCommand("hello", usage, desc, func(args ...string) ([]byte, error) {
		return []byte("hey what's up?"), nil
	})
}
532482
func main() {
	var addr, conf string
	flag.StringVar(&addr, "a", "127.0.0.1:9876", "`address` of server")
	flag.StringVar(&conf, "f", "server.json", "config `file` to use")
	flag.Parse()

	var id = new(core.Identity)
	data, err := ioutil.ReadFile(conf)
	if err != nil {
		exlib.Err(1, err, "reading config file")
	}

	err = json.Unmarshal(data, id)
	if err != nil {
		exlib.Err(1, err, "parsing config file")
	}

	tr, err := transport.New(exlib.Before, id)
	if err != nil {
		exlib.Err(1, err, "creating transport")
	}

	l, err := transport.Listen(addr, tr)
	if err != nil {
		exlib.Err(1, err, "setting up listener")
	}

	var errChan = make(chan error, 0)
	go func(ec <-chan error) {
		for {
			err, ok := <-ec
			if !ok {
				log.Warning("error channel closed, future errors will not be reported")
				break
			}
			log.Errorf("auto update error: %v", err)
		}
	}(errChan)

	log.Info("setting up auto-update")
	go l.AutoUpdate(nil, errChan)

	log.Info("listening on ", addr)
	exlib.Warn(serve(l), "serving listener")
}
169993
func (p *provisionee) Hello(ctx context.Context, arg keybase1.HelloArg) (res keybase1.HelloRes, err error) {
	close(p.start)
	res, err = p.arg.Provisionee.HandleHello(ctx, arg)
	if err != nil {
		p.done <- err
	}
	return res, err
}
1036767
func main() {
	app := gear.New()

	// Add logging middleware
	app.UseHandler(logging.Default(true))

	// Add router middleware
	router := gear.NewRouter()

	// try: http://127.0.0.1:3000/hello
	router.Get("/hello", func(ctx *gear.Context) error {
		return ctx.HTML(200, "<h1>Hello, Gear!</h1>")
	})

	// try: http://127.0.0.1:3000/test?query=hello
	router.Otherwise(func(ctx *gear.Context) error {
		return ctx.JSON(200, map[string]interface{}{
			"Host":    ctx.Host,
			"Method":  ctx.Method,
			"Path":    ctx.Path,
			"URL":     ctx.Req.URL.String(),
			"Headers": ctx.Req.Header,
		})
	})
	app.UseHandler(router)
	app.Error(app.Listen(":3000"))
}
1122917
func (c *UserController) SayHelloWorld() {
	c.Ctx.ResponseWriter.Status = 200
	c.Ctx.ResponseWriter.Write([]byte("Hello, World"))
}
1139688
func main() {
	restful.Add(newUserService())
	log.Print("start listening on localhost:8080")
	log.Fatal(http.ListenAndServe(":8080", nil))
}
310986
func main() {

	uri := os.Getenv("BFX_API_URI")
	key := os.Getenv("BFX_API_KEY")
	secret := os.Getenv("BFX_API_SECRET")
	p := websocket.NewDefaultParameters()
	p.URL = uri
	c := websocket.NewWithParams(p).Credentials(key, secret)

	err := c.Connect()
	if err != nil {
		log.Fatalf("connecting authenticated websocket: %s", err)
	}
	go func() {
		for msg := range c.Listen() {
			log.Printf("MSG RECV: %#v", msg)
		}
	}()

	//ctx, _ := context.WithTimeout(context.Background(), time.Second*1)
	//c.Authenticate(ctx)

	time.Sleep(time.Second * 10)
}
1284372
func main() {
	// Set up a connection to the server.
	cr, err := credentials.NewClientTLSFromFile("./testdata/out/GearTest.crt", "127.0.0.1")
	if err != nil {
		log.Fatalf("credentials error: %v", err)
	}
	conn, err := grpc.Dial("127.0.0.1:3000", grpc.WithTransportCredentials(cr))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	defer conn.Close()
	c := pb.NewGreeterClient(conn)

	for i := 0; i < 10; i++ {
		r, err := c.SayHello(context.Background(), &pb.HelloRequest{Name: strconv.Itoa(i)})
		if err != nil {
			log.Fatalf("could not greet: %v", err)
		}
		log.Printf("Greeting: %s", r.Message)
	}

	// bench(c)
}
701808
func main() {

	// init a connection
	s, err := solr.Init("localhost", 8983, "collection-name")

	if err != nil {
		fmt.Println(err)
		return
	}

	// build an update document, in this case removing two documents
	f := map[string]interface{}{
		"delete": map[string]interface{}{
			"id": 22,
		},
	}

	// send off the update (2nd parameter indicates we also want to commit the operation)
	resp, err := s.Update(f, true)

	if err != nil {
		fmt.Println("error =>", err)
	} else {
		fmt.Println("resp =>", resp)
	}
}