diff --git a/concurrency/simplesem/main.go b/concurrency/simplesem/main.go new file mode 100644 index 0000000..8db0d50 --- /dev/null +++ b/concurrency/simplesem/main.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + concurrentCount := 5 + sem := make(chan bool, concurrentCount) + + for i := 0; i < 100; i++ { + sem <- true + go func(i int) { + dummyProcess(i) + <-sem + }(i) + } + time.Sleep(time.Second * 20) +} + +func dummyProcess(i int) { + fmt.Printf("Process Dummy %v \n", i) + time.Sleep(time.Second) +} diff --git a/urfavecli/main.go b/urfavecli/main.go new file mode 100644 index 0000000..1e7a9b6 --- /dev/null +++ b/urfavecli/main.go @@ -0,0 +1,27 @@ +package main + +import ( + "fmt" + "os" + + "github.com/urfave/cli" +) + +func main() { + app := cli.NewApp() + app.Name = "hello_cli" + app.Usage = "Print hello world" + app.Flags = []cli.Flag{ + cli.StringFlag{ + Name: "name, n", + Value: "World", + Usage: "Who to say hello to.", + }, + } + app.Action = func(c *cli.Context) error { + name := c.GlobalString("name") + fmt.Printf("Hello %s!\n", name) + return nil + } + app.Run(os.Args) +}