Exemple #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)
	}
}
Exemple #2
0
// checkHash is true, if the existing gofn function has the same fnv hash-value.
func (r *Run) checkHash(name string, newFnvHash uint32) (bool, error) {
	if ok := r.functionExists(name); !ok {
		return ok, nil
	}
	info, err := info.ByName(name, r.bindir, r.sep)
	if err != nil {
		return false, err
	}
	return info.FnvHash == newFnvHash, nil
}
Exemple #3
0
// Clean removes the oldest gofn functions if there are more than itemMax.
// itemMax is specified by the environment variable GOFN_MAX or defaults to 200.
func (c *Cleaner) Clean() {
	var arr cleanItems
	for _, name := range info.ListFunctions(c.bindir) {
		info, err := info.ByName(name, c.bindir, c.sep)
		if err != nil {
			continue
		}
		//arr = append(arr, info.Time.Unix())
		arr = append(arr, cleanItem{
			name: name,
			time: info.Time.Unix(),
		})
	}
	sort.Sort(arr)
	for _, item := range arr.notNeeded(c.itemMax) {
		deleteGofn(item.nameToPath(c.bindir, c.sep))
	}
}