Exemplo n.º 1
0
func main() {
	gosh.InitMain()
	flag.Parse()
	sh := gosh.NewShell(nil)
	defer sh.Cleanup()
	cwd, err := os.Getwd()
	ok(err)
	hostname := "localhost"
	if !*loopback {
		hostname, err = ip()
		ok(err)
	}
	addr := fmt.Sprintf("%s:%d", hostname, *port)
	httpAddr := fmt.Sprintf("%s:%d", hostname, *port+100)
	c := sh.FuncCmd(serve, addr, strings.Split(*peerAddrs, ","))
	c.AddStderrWriter(os.Stderr)
	c.Start()
	c.AwaitVars("ready")
	// Note, the "open" command doesn't support query strings in file urls.
	fmt.Printf("http://%s/demo/index.html?addr=%s\n", httpAddr, url.QueryEscape(addr))
	ok(http.ListenAndServe(httpAddr, http.FileServer(http.Dir(cwd))))
	c.Wait()
}
Exemplo n.º 2
0
func TestMain(m *testing.M) {
	gosh.InitMain()
	os.Exit(m.Run())
}
Exemplo n.º 3
0
func main() {
	gosh.InitMain()
	ExampleCmd()
	ExampleFuncCmd()
}