當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Strings.Difference方法代碼示例

本文整理匯總了Golang中github.com/juju/utils/set.Strings.Difference方法的典型用法代碼示例。如果您正苦於以下問題:Golang Strings.Difference方法的具體用法?Golang Strings.Difference怎麽用?Golang Strings.Difference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/juju/utils/set.Strings的用法示例。


在下文中一共展示了Strings.Difference方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: AssertExportedFields

func (s *MigrationSuite) AssertExportedFields(c *gc.C, doc interface{}, fields set.Strings) {
	expected := getExportedFields(doc)
	unknown := expected.Difference(fields)
	removed := fields.Difference(expected)
	// If this test fails, it means that extra fields have been added to the
	// doc without thinking about the migration implications.
	c.Check(unknown, gc.HasLen, 0)
	c.Assert(removed, gc.HasLen, 0)
}
開發者ID:AlexisBruemmer,項目名稱:juju,代碼行數:9,代碼來源:migration_internal_test.go

示例2: removeDiff

// removeDiff removes every path in oldManifest that is not present in newManifest.
func (d *manifestDeployer) removeDiff(oldManifest, newManifest set.Strings) error {
	diff := oldManifest.Difference(newManifest)
	for _, path := range diff.SortedValues() {
		fullPath := filepath.Join(d.charmPath, filepath.FromSlash(path))
		if err := os.RemoveAll(fullPath); err != nil {
			return err
		}
	}
	return nil
}
開發者ID:imoapps,項目名稱:juju,代碼行數:11,代碼來源:manifest_deployer.go

示例3: TestUninitialized

func (stringSetSuite) TestUninitialized(c *gc.C) {
	var uninitialized set.Strings
	c.Assert(uninitialized.Size(), gc.Equals, 0)
	c.Assert(uninitialized.IsEmpty(), gc.Equals, true)
	// You can get values and sorted values from an unitialized set.
	AssertValues(c, uninitialized)
	// All contains checks are false
	c.Assert(uninitialized.Contains("foo"), gc.Equals, false)
	// Remove works on an uninitialized Strings
	uninitialized.Remove("foo")

	var other set.Strings
	// Union returns a new set that is empty but initialized.
	c.Assert(uninitialized.Union(other), gc.DeepEquals, set.NewStrings())
	c.Assert(uninitialized.Intersection(other), gc.DeepEquals, set.NewStrings())
	c.Assert(uninitialized.Difference(other), gc.DeepEquals, set.NewStrings())

	other = set.NewStrings("foo", "bar")
	c.Assert(uninitialized.Union(other), gc.DeepEquals, other)
	c.Assert(uninitialized.Intersection(other), gc.DeepEquals, set.NewStrings())
	c.Assert(uninitialized.Difference(other), gc.DeepEquals, set.NewStrings())
	c.Assert(other.Union(uninitialized), gc.DeepEquals, other)
	c.Assert(other.Intersection(uninitialized), gc.DeepEquals, set.NewStrings())
	c.Assert(other.Difference(uninitialized), gc.DeepEquals, other)

	// Once something is added, the set becomes initialized.
	uninitialized.Add("foo")
	AssertValues(c, uninitialized, "foo")
}
開發者ID:natefinch,項目名稱:utils,代碼行數:29,代碼來源:strings_test.go


注:本文中的github.com/juju/utils/set.Strings.Difference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。