Ejemplo n.º 1
0
// lookup for an specific installed go version
func LookupInstalledVersion(version string) bool {
	installed, err := cache.GetInstalled(
		cache.Tags(), cache.AvailableSources(), cache.AvailableBinaries())
	if err != nil {
		log.Fatal(err)
	}

	for _, v := range installed {
		if v == version {
			return true
		}
	}

	return false
}
Ejemplo n.º 2
0
// implements the Runner interface returning back a list of installed
// go versions, a list of not installed versions or all versions depending
// on the list options
func (l *List) Run() (string, error) {
	tags := cache.Tags()
	sources := cache.AvailableSources()
	binaries := cache.AvailableBinaries()

	versions := map[string][]string{
		"installed": []string{},
		"available": []string{},
	}
	installed, err := cache.GetInstalled(tags, sources, binaries)
	if err != nil {
		fmt.Println("while running List command:", err)
		return "error while running the command", err
	}
	versions["installed"] = append(versions["installed"], installed...)
	versions["available"] = append(
		versions["available"],
		cache.GetNonInstalled(installed, tags, sources, binaries)...,
	)

	return l.display(versions)
}