Beispiel #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
}
Beispiel #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)
}
Beispiel #3
0
		})

		Context("With version 1.4beta1", func() {
			It("Should return f2fece0c9f9cdc6e8a85ab56b7f1ffcb57c3e7cd", func() {
				sha1, err := cache.Checksum("1.4beta1")

				Expect(sha1).To(
					Equal("f2fece0c9f9cdc6e8a85ab56b7f1ffcb57c3e7cd"))
				Expect(err).NotTo(HaveOccurred())
			})
		})
	})

	Describe("AvilableSources", func() {
		It("Should return 15 sources", func() {
			Expect(len(cache.AvailableSources())).To(Equal(15))
		})
	})

	Describe("AvilableBinaries", func() {
		It("Should return 114 binaries", func() {
			Expect(len(cache.AvailableBinaries())).To(Equal(114))
		})
	})

	Describe("AvilableDonwloads", func() {
		It("Should return 15 sources plus 114 binaries", func() {
			Expect(len(cache.AvailableDownloads())).To(Equal(15 + 114))
		})
	})