Beispiel #1
0
// Packages returns an alphabetically ordered list of unique package names that are referenced by this type configuration.
func (c *TypesConfiguration) Packages(additionalPackages ...string) []string {
	packages := additionalPackages
	seenPackages := util.StringSet{}
	for _, additionalPackage := range additionalPackages {
		seenPackages.Set(additionalPackage)
	}

	for _, typeDef := range c.Types {
		if seenPackages.Contains(typeDef.Package) {
			continue
		}

		seenPackages.Set(typeDef.Package)
		packages = append(packages, typeDef.Package)
	}

	sort.Strings(packages)
	return packages
}
Beispiel #2
0
package util_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	"github.com/fgrosse/goldi/util"
)

var _ = Describe("StringSet", func() {
	It("should have a simple method to check if a key is set", func() {
		s := util.StringSet{}
		key := "test"
		Expect(s.Contains(key)).To(BeFalse())
		s.Set(key)
		Expect(s.Contains(key)).To(BeTrue())
	})
})