// The app entry point.
978088
func main() {
	// Imports the hello component declared above in order to make it loadable
	// in a page or usable in other components.
	//
	// Imported component can be used as URL or html tags by referencing them by
	// their lowercased names.
	// E.g:
	//  Hello   => hello
	//  foo.Bar => foo.bar
	app.Import(&Hello{})

	// Defines the component to load when an URL without path is loaded.
	app.DefaultPath = "/hello"

	// Runs the app in the browser.
	if err := app.Run(); err != nil {
		log.Print(err)
	}
}
559904
func Init(app_name string) bool {
	papp_name := C.CString(app_name)
	defer C.free(unsafe.Pointer(papp_name))

	return bool(C.notify_init(papp_name) != 0)
}
1228622
func (a *App) Cmd(runMode string) AppCmd {
	a.cmd = NewAppCmd(a.BinaryPath, a.Port, runMode, a.Paths)
	return a.cmd
}
429061
func main() {

	const htmlBody = `
<!DOCTYPE html>
<html>
  <head>
    <link href="/hello.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <h1>Hello, Gear!</h1>
  </body>
</html>`

	const pushBody = `
h1 {
  color: red;
}
`

	app := gear.New()

	app.UseHandler(logging.Default(true))
	app.Use(favicon.New("./testdata/favicon.ico"))

	router := gear.NewRouter()
	router.Get("/", func(ctx *gear.Context) error {
		ctx.Res.Push("/hello.css", &http.PushOptions{Method: "GET"})
		return ctx.HTML(200, htmlBody)
	})
	router.Get("/hello.css", func(ctx *gear.Context) error {
		ctx.Type("text/css")
		return ctx.End(200, []byte(pushBody))
	})
	app.UseHandler(router)
	app.Error(app.ListenTLS(":3000", "./testdata/out/test.crt", "./testdata/out/test.key"))
}
923497
func main() {
	request := []string{"Hello world"}
	reply := []string{}
	var err error

	endpoints := len(os.Args) - 1
	if endpoints == 0 {
		fmt.Printf("I: syntax: %s <endpoint> ...\n", os.Args[0])
	} else if endpoints == 1 {
		//  For one endpoint, we retry N times
		for retries := 0; retries < MAX_RETRIES; retries++ {
			endpoint := os.Args[1]
			reply, err = try_request(endpoint, request)
			if err == nil {
				break //  Successful
			}
			fmt.Printf("W: no response from %s, retrying...\n", endpoint)
		}
	} else {
		//  For multiple endpoints, try each at most once
		for endpoint_nbr := 0; endpoint_nbr < endpoints; endpoint_nbr++ {
			endpoint := os.Args[endpoint_nbr+1]
			reply, err = try_request(endpoint, request)
			if err == nil {
				break //  Successful
			}
			fmt.Println("W: no response from", endpoint)
		}
	}
	if len(reply) > 0 {
		fmt.Printf("Service is running OK: %q\n", reply)
	}
}
839999
func (c context) start(wait time.Duration, delay time.Duration) error {
	procPaths, err := c.lookupProcessPaths()
	if err != nil {
		return err
	}

	if err := OpenAppDarwin(procPaths.appPath, c.log); err != nil {
		c.log.Warningf("Error opening app: %s", err)
	}

	// Check to make sure processes started
	c.log.Debugf("Checking processes: %#v", procPaths)
	serviceProcErr := c.checkProcess(procPaths.serviceProcPath, wait, delay)
	kbfsProcErr := c.checkProcess(procPaths.kbfsProcPath, wait, delay)
	appProcErr := c.checkProcess(procPaths.appProcPath, wait, delay)

	return util.CombineErrors(serviceProcErr, kbfsProcErr, appProcErr)
}
1281018
func main() {

	swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
	if err != nil {
		log.Fatalln(err)
	}

	api := operations.NewTaskTrackerAPI(swaggerSpec)
	server := restapi.NewServer(api)
	defer server.Shutdown()

	parser := flags.NewParser(server, flags.Default)
	parser.ShortDescription = "Issue Tracker API"
	parser.LongDescription = "This application implements a very simple issue tracker.\nIt's implemented as an API which is described by this swagger spec document.\n\nThe go-swagger project uses this specification to test the code generation.\nThis document contains all possible values for a swagger definition.\nThis means that it exercises the framework relatively well.\n"

	server.ConfigureFlags()
	for _, optsGroup := range api.CommandLineOptionsGroups {
		_, err := parser.AddGroup(optsGroup.ShortDescription, optsGroup.LongDescription, optsGroup.Options)
		if err != nil {
			log.Fatalln(err)
		}
	}

	if _, err := parser.Parse(); err != nil {
		code := 1
		if fe, ok := err.(*flags.Error); ok {
			if fe.Type == flags.ErrHelp {
				code = 0
			}
		}
		os.Exit(code)
	}

	server.ConfigureAPI()

	if err := server.Serve(); err != nil {
		log.Fatalln(err)
	}

}
766254
func main() {
	flag.Parse()

	// set the log level to Trace
	log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(false))))

	// register a single ping-pong service
	services := map[string]adapters.ServiceFunc{
		"ping-pong": func(ctx *adapters.ServiceContext) (node.Service, error) {
			return newPingPongService(ctx.Config.ID), nil
		},
	}
	adapters.RegisterServices(services)

	// create the NodeAdapter
	var adapter adapters.NodeAdapter

	switch *adapterType {

	case "sim":
		log.Info("using sim adapter")
		adapter = adapters.NewSimAdapter(services)

	case "exec":
		tmpdir, err := ioutil.TempDir("", "p2p-example")
		if err != nil {
			log.Crit("error creating temp dir", "err", err)
		}
		defer os.RemoveAll(tmpdir)
		log.Info("using exec adapter", "tmpdir", tmpdir)
		adapter = adapters.NewExecAdapter(tmpdir)

	default:
		log.Crit(fmt.Sprintf("unknown node adapter %q", *adapterType))
	}

	// start the HTTP API
	log.Info("starting simulation server on 0.0.0.0:8888...")
	network := simulations.NewNetwork(adapter, &simulations.NetworkConfig{
		DefaultService: "ping-pong",
	})
	if err := http.ListenAndServe(":8888", simulations.NewServer(network)); err != nil {
		log.Crit("error starting simulation server", "err", err)
	}
}
119649
func main() {
	// Init DB and plan to close it at the end of the programme
	dbconn.Connect()
	defer dbconn.DB.Close()

	// Set GIN in production mode if run in production
	if !config.GDevEnv {
		gin.SetMode(gin.ReleaseMode)
	}

	// Init router
	router := gin.Default()
	router.Use(cors.New(apitool.DefaultCORSConfig()))

	// User component
	userComponent := user.New(rest.New(service.New(repo.New())))
	userComponent.AttachPublicAPI(router.Group("/api/v1"))
	userComponent.AttachPrivateAPI(router.Group("/api/private-v1"))

	// Start router
	go log.Println("Service user started: Navigate to " + config.GAppUrl)
	router.Run(":" + config.GPort)
}
636600
func main() {
	in, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		log.Fatal(err)
	}
	out, err := yaml.YAMLToJSON(in)
	if err != nil {
		log.Fatal(err)
	}
	_, err = os.Stdout.Write(out)
	if err != nil {
		log.Fatal(err)
	}
}
975209
func (cmd AppCmd) Run() {
	utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args)
	if err := cmd.Cmd.Run(); err != nil {
		utils.Logger.Fatal("Error running:", "error", err)
	}
}
773241
func (cfg *Config) Main(c context.Context, argv []string, env environ.Env) int {
	if len(argv) == 0 {
		panic("zero-length argument slice")
	}

	// Implementation of "checkWrapper": if CheckWrapperENV is set, we immediately
	// exit with a non-zero value.
	if wrapperCheck(env) {
		return 1
	}

	defaultLogLevel := logging.Error
	if env.GetEmpty(LogTraceENV) != "" {
		defaultLogLevel = logging.Debug
	}

	c = gologger.StdConfig.Use(c)
	c = logging.SetLevel(c, defaultLogLevel)

	a := application{
		Config: cfg,
		opts: vpython.Options{
			EnvConfig: venv.Config{
				BaseDir:           "", // (Determined below).
				MaxHashLen:        6,
				SetupEnv:          env,
				Package:           cfg.VENVPackage,
				PruneThreshold:    cfg.PruneThreshold,
				MaxPrunesPerSweep: cfg.MaxPrunesPerSweep,
				Loader:            cfg.PackageLoader,
			},
			BaseWheels: cfg.BaseWheels,
			WaitForEnv: true,
			SpecLoader: cfg.SpecLoader,
			Environ:    env,
		},
		logConfig: logging.Config{
			Level: defaultLogLevel,
		},
	}

	return run(c, func(c context.Context) error {
		return a.mainImpl(c, argv[0], argv[1:])
	})
}
1215181
func main() {
	rootCmd := cmds.NewCmdOsm()
	dir := runtime.GOPath() + "/src/github.com/appscode/osm/docs/reference"
	fmt.Printf("Generating cli markdown tree in: %v\n", dir)
	err := os.RemoveAll(dir)
	if err != nil {
		log.Fatalln(err)
	}
	err = os.MkdirAll(dir, 0755)
	if err != nil {
		log.Fatalln(err)
	}

	filePrepender := func(filename string) string {
		name := filepath.Base(filename)
		base := strings.TrimSuffix(name, path.Ext(name))
		data := struct {
			ID      string
			Name    string
			Version string
			RootCmd bool
		}{
			strings.Replace(base, "_", "-", -1),
			strings.Title(strings.Replace(base, "_", " ", -1)),
			version,
			!strings.ContainsRune(base, '_'),
		}
		var buf bytes.Buffer
		if err := tplFrontMatter.ExecuteTemplate(&buf, "cmd", data); err != nil {
			log.Fatalln(err)
		}
		return buf.String()
	}

	linkHandler := func(name string) string {
		return "/docs/reference/" + name
	}
	doc.GenMarkdownTreeCustom(rootCmd, dir, filePrepender, linkHandler)

	index := filepath.Join(dir, "_index.md")
	f, err := os.OpenFile(index, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
	if err != nil {
		log.Fatalln(err)
	}
	err = tplFrontMatter.ExecuteTemplate(f, "index", struct{ Version string }{version})
	if err != nil {
		log.Fatalln(err)
	}
	if err := f.Close(); err != nil {
		log.Fatalln(err)
	}
}
196543
func main() {
	app := cli.NewApp()
	app.Name = path.Base(os.Args[0])
	app.Author = "Manfred Touron"
	app.Email = "https://github.com/moul"
	app.Version = "1.0.0-dev"
	app.Usage = "Anonymize UUIDs outputs"

	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "hexspeak",
			Usage: "Generate hexspeak style fake UUIDs",
		},
		cli.BoolFlag{
			Name:  "random, r",
			Usage: "Generate random fake UUIDs",
		},
		cli.BoolFlag{
			Name:  "keep-beginning",
			Usage: "Keep first part of the UUID unchanged",
		},
		cli.BoolFlag{
			Name:  "keep-end",
			Usage: "Keep last part of the UUID unchanged",
		},
		cli.StringFlag{
			Name:  "prefix, p",
			Usage: "Prefix generated UUIDs",
		},
		cli.StringFlag{
			Name:  "suffix",
			Usage: "Suffix generated UUIDs",
		},
	}

	app.Action = action
	app.Run(os.Args)
}
490361
func runApp(c *model.CommandConfig) (err error) {
	if c.Run.Mode == "" {
		c.Run.Mode = "dev"
	}

	revel_path, err := model.NewRevelPaths(c.Run.Mode, c.ImportPath, "", model.NewWrappedRevelCallback(nil, c.PackageResolver))
	if err != nil {
		return utils.NewBuildIfError(err, "Revel paths")
	}
	if c.Run.Port > -1 {
		revel_path.HTTPPort = c.Run.Port
	} else {
		c.Run.Port = revel_path.HTTPPort
	}

	utils.Logger.Infof("Running %s (%s) in %s mode\n", revel_path.AppName, revel_path.ImportPath, revel_path.RunMode)
	utils.Logger.Debug("Base path:", "path", revel_path.BasePath)

	// If the app is run in "watched" mode, use the harness to run it.
	if revel_path.Config.BoolDefault("watch", true) && revel_path.Config.BoolDefault("watch.code", true) {
		utils.Logger.Info("Running in watched mode.")
		runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v}`, revel_path.RunMode, c.Verbose)
		if c.HistoricMode {
			runMode = revel_path.RunMode
		}
		// **** Never returns.
		harness.NewHarness(c, revel_path, runMode, c.Run.NoProxy).Run()
	}

	// Else, just build and run the app.
	utils.Logger.Debug("Running in live build mode.")
	app, err := harness.Build(c, revel_path)
	if err != nil {
		utils.Logger.Errorf("Failed to build app: %s", err)
	}
	app.Port = revel_path.HTTPPort
	runMode := fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v}`, app.Paths.RunMode, c.Verbose)
	if c.HistoricMode {
		runMode = revel_path.RunMode
	}
	app.Cmd(runMode).Run()
	return
}
583587
func OpenAppDarwin(appPath string, log process.Log) error {
	return openAppDarwin("/usr/bin/open", appPath, time.Second, log)
}
710096
func RunApp(cmd *commands.Command, args []string) int {
	// The default app path is the current working directory
	appPath, _ := os.Getwd()

	// If an argument is presented, we use it as the app path
	if len(args) != 0 && args[0] != "watchall" {
		if path.IsAbs(args[0]) {
			appPath = args[0]
		} else {
			appPath = path.Join(appPath, args[0])
		}
	}

	if utils.IsInGOPATH(appPath) {
		if found, _gopath, _path := utils.SearchGOPATHs(appPath); found {
			appPath = _path
			appname = path.Base(appPath)
			currentGoPath = _gopath
		} else {
			beeLogger.Log.Fatalf("No application '%s' found in your GOPATH", appPath)
		}
		if strings.HasSuffix(appname, ".go") && utils.IsExist(appPath) {
			beeLogger.Log.Warnf("The appname is in conflict with file's current path. Do you want to build appname as '%s'", appname)
			beeLogger.Log.Info("Do you want to overwrite it? [yes|no] ")
			if !utils.AskForConfirmation() {
				return 0
			}
		}
	} else {
		beeLogger.Log.Warn("Running application outside of GOPATH")
		appname = path.Base(appPath)
		currentGoPath = appPath
	}

	beeLogger.Log.Infof("Using '%s' as 'appname'", appname)

	beeLogger.Log.Debugf("Current path: %s", utils.FILE(), utils.LINE(), appPath)

	if runmode == "prod" || runmode == "dev" {
		os.Setenv("BEEGO_RUNMODE", runmode)
		beeLogger.Log.Infof("Using '%s' as 'runmode'", os.Getenv("BEEGO_RUNMODE"))
	} else if runmode != "" {
		os.Setenv("BEEGO_RUNMODE", runmode)
		beeLogger.Log.Warnf("Using '%s' as 'runmode'", os.Getenv("BEEGO_RUNMODE"))
	} else if os.Getenv("BEEGO_RUNMODE") != "" {
		beeLogger.Log.Warnf("Using '%s' as 'runmode'", os.Getenv("BEEGO_RUNMODE"))
	}

	var paths []string
	readAppDirectories(appPath, &paths)

	// Because monitor files has some issues, we watch current directory
	// and ignore non-go files.
	for _, p := range config.Conf.DirStruct.Others {
		paths = append(paths, strings.Replace(p, "$GOPATH", currentGoPath, -1))
	}

	if len(extraPackages) > 0 {
		// get the full path
		for _, packagePath := range extraPackages {
			if found, _, _fullPath := utils.SearchGOPATHs(packagePath); found {
				readAppDirectories(_fullPath, &paths)
			} else {
				beeLogger.Log.Warnf("No extra package '%s' found in your GOPATH", packagePath)
			}
		}
		// let paths unique
		strSet := make(map[string]struct{})
		for _, p := range paths {
			strSet[p] = struct{}{}
		}
		paths = make([]string, len(strSet))
		index := 0
		for i := range strSet {
			paths[index] = i
			index++
		}
	}

	files := []string{}
	for _, arg := range mainFiles {
		if len(arg) > 0 {
			files = append(files, arg)
		}
	}
	if downdoc == "true" {
		if _, err := os.Stat(path.Join(appPath, "swagger", "index.html")); err != nil {
			if os.IsNotExist(err) {
				downloadFromURL(swaggerlink, "swagger.zip")
				unzipAndDelete("swagger.zip")
			}
		}
	}

	// Start the Reload server (if enabled)
	if config.Conf.EnableReload {
		startReloadServer()
	}
	if gendoc == "true" {
		NewWatcher(paths, files, true)
		AutoBuild(files, true)
	} else {
		NewWatcher(paths, files, false)
		AutoBuild(files, false)
	}

	for {
		<-exit
		runtime.Goexit()
	}
}