Example #1
0
func printFunctions() {
	c := make(chan string, 20)
	var wg sync.WaitGroup
	sep := string(os.PathSeparator)
	bindir, err := bindir.Path()
	if err != nil {
		log.Fatalln(err)
	}
	go func() {
		for _, name := range info.ListFunctions(bindir) {
			wg.Add(1)
			go func(name, bindir, sep string) {
				info, err := info.ByName(name, bindir, sep)
				if err != nil {
					return
				}
				time := info.Time.Format("2006-01-02 15:04")
				c <- fmt.Sprintf("%s  %v  %s", name, time, info.Goversion)
				wg.Done()
			}(name, bindir, sep)
		}
		wg.Wait()
		close(c)
	}()
	for row := range c {
		fmt.Println(row)
	}
}
Example #2
0
// randomlyRunClean executest the cleaner with a chance of 1 in 30.
func randomlyRunClean() {
	max := 30
	rand.Seed(time.Now().UnixNano())
	if n := rand.Intn(max); n == 0 {
		bindir, err := bindir.Path()
		if err != nil {
			log.Fatalln(err)
		}
		clean.NewCleaner(bindir).Clean()
	}
}
Example #3
0
File: gofn.go Project: thibran/gofn
func main() {
	flag.Usage = printHelp
	// print help if no arguments have been passed
	if len(os.Args) == 1 {
		noFlags = true
		os.Args = append(os.Args, "-h")
	}
	// parse
	f := run.ParseAndCreateFunction()
	if f.Debug {
		run.PrintDebug(f)
		os.Exit(0)
	}
	// bild and or run gofn-function
	bindir, err := bindir.Path()
	if err != nil {
		panic(err)
	}
	r := run.NewRun(bindir)
	if err = r.Exec(f); err != nil {
		os.Exit(1)
	}
}