当前位置: 首页>>代码示例>>Golang>>正文


Golang gt.New函数代码示例

本文整理汇总了Golang中github.com/kardianos/govendor/internal/gt.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestTagList

func TestTagList(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
		gt.File("a_test.go", "testing", "bytes"),
		gt.FileBuild("b.go", "appengine", "encoding/hex"),
	)
	g.Setup("co2/pk1",
		gt.File("a_not_test_foo.go", "encoding/csv"),
		gt.File("a_test.go", "testing", "encoding/json"),
		gt.FileBuild("b.go", "appengine", "encoding/binary"),
	)
	g.In("co1")
	c := ctx(g)
	c.IgnoreBuild("test appengine")

	list(g, c, "co1 list", `e co2/pk1 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s encoding/csv < ["co2/pk1"]
s encoding/hex < ["co1/pk1"]
s testing < ["co1/pk1"]
`)
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:26,代码来源:context_test.go

示例2: TestUnused

func TestUnused(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.Setup("co1/vendor/a",
		gt.File("a.go", "encoding/csv"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "bytes"),
	)
	g.Setup("co3/pk1",
		gt.File("a.go", "strings"),
	)

	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co3/pk1", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
u co1/vendor/a [a] < []
u co1/vendor/co3/pk1 [co3/pk1] < []
l co1/pk1 < []
s bytes < ["co1/vendor/co2/pk1"]
s encoding/csv < ["co1/vendor/a"]
s strings < ["co1/vendor/co3/pk1"]
`)
}
开发者ID:jpillora,项目名称:govendor,代码行数:35,代码来源:context_test.go

示例3: TestDuplicatePackage

func TestDuplicatePackage(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co3/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "co3/pk1"),
	)
	g.Setup("co3/pk1",
		gt.File("a.go", "strings"),
	)
	g.In("co2")
	Vendor(g, "co2 init", "init", "")
	Vendor(g, "co2 add", "add +ext", "")

	g.In("co1")
	Vendor(g, "co1 init", "init", "")
	Vendor(g, "co1 pre list", "list", `e co2/pk1
e co3/pk1
e co3/pk1
l co1/pk1
`)
	Vendor(g, "co1 add", "add -long +ext", "")
	Vendor(g, "co1 list", "list", `v co2/pk1
v co3/pk1
l co1/pk1
`)
}
开发者ID:leeprovoost,项目名称:govendor,代码行数:30,代码来源:run_test.go

示例4: TestTagAdd15

func TestTagAdd15(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
		gt.File("a_test.go", "bytes", "testing"),
		gt.FileBuild("b.go", "appengine", "encoding/csv"),
	)
	g.In("co1")
	c := ctx15(g)
	c.IgnoreBuild("test appengine")

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
l co1/pk1 < []
s strings < ["co1/vendor/co2/pk1"]
`)

	checkPathBase := filepath.Join(g.Current(), "vendor", "co2", "pk1")
	if _, err := os.Stat(filepath.Join(checkPathBase, "a_test.go")); err == nil {
		t.Error("a_test.go should not be copied into vendor folder")
	}
	if _, err := os.Stat(filepath.Join(checkPathBase, "b.go")); err == nil {
		t.Error("b.go should not be copied into vendor folder")
	}
}
开发者ID:kouhin,项目名称:govendor,代码行数:33,代码来源:context_test.go

示例5: TestVendorProgram

func TestVendorProgram(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/main",
		gt.File("b.go", "bytes"),
	)
	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/main", AddUpdate))

	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 list", `
p co1/vendor/co2/main [co2/main] < []
l co1/pk1 < []
s bytes < ["co1/vendor/co2/main"]
s strings < ["co1/pk1"]
`)
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:25,代码来源:context_test.go

示例6: TestEllipsis

func TestEllipsis(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk1/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	Vendor(g, "co1 init", "init", "")
	Vendor(g, "", "list", `e co2/pk1
e co2/pk1/pk2
l co1/pk1
`)
	Vendor(g, "co1 add ext", "add co2/pk1/...", "")
	Vendor(g, "co1 list", "list", `v co2/pk1
v co2/pk1/pk2
l co1/pk1
`)
}
开发者ID:leeprovoost,项目名称:govendor,代码行数:26,代码来源:run_test.go

示例7: TestImportSimple15

func TestImportSimple15(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx15(g)
	g.Check(c.ModifyImport("co2/pk1", AddUpdate))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())
	expected := `v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
e co2/pk2 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/vendor/co2/pk1" "co2/pk2"]
`
	list(g, c, "same", expected)

	c = ctx15(g)
	list(g, c, "new", expected)

	vendorFile15(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"canonical": "co2/pk1",
			"comment": "",
			"local": "vendor/co2/pk1",
			"revision": "",
			"revisionTime": ""
		}
	]
}`)

	// Now remove an import.
	g.Check(c.ModifyImport("co2/pk1", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())
	list(g, c, "co1 remove", `e co2/pk1 < ["co1/pk1"]
e co2/pk2 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co2/pk1" "co2/pk2"]
`)
}
开发者ID:kouhin,项目名称:govendor,代码行数:55,代码来源:context_test.go

示例8: TestVendor

func TestVendor(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
		gt.File("b.go", "bytes"),
	)
	g.Setup("co2/vendor/a",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "a"),
	)

	g.In("co1")
	c := ctx(g)

	list(g, c, "co1 list", `e co2/pk1 < ["co1/pk1"]
e co2/vendor/a [a] < ["co2/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co2/vendor/a"]
`)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co2/vendor/a", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `v co1/vendor/a [a] < ["co1/vendor/co2/pk1"]
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/vendor/a"]
`)

	vendorFile(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"origin": "co2/vendor/a",
			"path": "a",
			"revision": ""
		},
		{
			"path": "co2/pk1",
			"revision": ""
		}
	]
}
`)
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:54,代码来源:context_test.go

示例9: TestAddMissing

func TestAddMissing(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.In("co1")
	c := ctx(g)

	err := c.ModifyImport("co2/pk1", Add)
	if _, is := err.(ErrNotInGOPATH); !is {
		t.Fatalf("Expected not in GOPATH error. Got %v", err)
	}
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:15,代码来源:context_test.go

示例10: TestTree

func TestTree(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk1/c_code",
		gt.File("stub.c"),
	)
	g.Setup("co2/pk1/go_code",
		gt.File("stub.go", "strings"),
	)
	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/pk1/^", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add list", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
u co1/vendor/co2/pk1/go_code [co2/pk1/go_code] < []
l co1/pk1 < []
s strings < ["co1/vendor/co2/pk1" "co1/vendor/co2/pk1/go_code"]
`)
	tree(g, c, "co1 after add tree", `
/pk1/a.go
/vendor/co2/pk1/a.go
/vendor/co2/pk1/c_code/stub.c
/vendor/co2/pk1/go_code/stub.go
/vendor/vendor.json
`)

	g.Check(c.ModifyImport("co2/pk1", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	tree(g, c, "co1 after remove tree", `
/pk1/a.go
/vendor/vendor.json
`)
}
开发者ID:jpillora,项目名称:govendor,代码行数:46,代码来源:context_test.go

示例11: TestMissing

func TestMissing(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co3/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "bytes"),
	)
	g.Setup("co3/pk1",
		gt.File("a.go", "strings"),
	)

	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.ModifyImport("co3/pk1", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	list(g, c, "co1 after add", `
v co1/vendor/co2/pk1 [co2/pk1] < ["co1/pk1"]
v co1/vendor/co3/pk1 [co3/pk1] < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/vendor/co2/pk1"]
s strings < ["co1/vendor/co3/pk1"]
`)

	g.In("co1")
	c = ctx(g)

	g.Remove("co1/vendor/co2/pk1")

	g.Remove("co1/vendor/co3/pk1")
	g.Remove("co3/pk1")

	list(g, c, "co1 after remove", `
e co2/pk1 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co2/pk1"]
m co3/pk1 < ["co1/pk1"]
`)
}
开发者ID:jpillora,项目名称:govendor,代码行数:45,代码来源:context_test.go

示例12: TestImportSimple

func TestImportSimple(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx14(g)
	g.Check(c.ModifyImport("co2/pk1", AddUpdate))

	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	vendorFile14(g, `{
	"comment": "",
	"ignore": "",
	"package": [
		{
			"path": "co2/pk1",
			"revision": ""
		}
	]
}`)

	expected := `v co1/internal/co2/pk1 [co2/pk1] < ["co1/pk1"]
e co2/pk2 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co1/internal/co2/pk1" "co2/pk2"]
`

	list(g, c, "same", expected)

	c = ctx14(g)
	list(g, c, "new", expected)
}
开发者ID:fabxc,项目名称:govendor,代码行数:44,代码来源:context_test.go

示例13: TestRemove

func TestRemove(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx(g)

	g.Check(c.ModifyImport("co2/pk1", Add))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	g.In("co2/pk1")
	// Change directory to let windows delete directory.
	current := g.Current()
	g.In("co1")
	err := os.RemoveAll(current)
	if err != nil {
		g.Fatal(err)
	}

	g.Check(c.ModifyImport("co2/pk1", Remove))
	g.Check(c.Alter())
	g.Check(c.WriteVendorFile())

	vi, err := os.Stat(filepath.Join(c.RootDir, c.VendorFolder))
	if err != nil {
		t.Fatal("vendor folder should still be present", err)
	}
	if vi.IsDir() == false {
		t.Fatal("vendor folder is not a dir")
	}
}
开发者ID:tedoc2000,项目名称:govendor,代码行数:38,代码来源:context_test.go

示例14: TestSimple

func TestSimple(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1", "co2/pk2"),
		gt.File("b.go", "co2/pk1", "bytes"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "strings"),
	)
	g.Setup("co2/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx14(g)
	list(g, c, "initial", `e co2/pk1 < ["co1/pk1"]
e co2/pk2 < ["co1/pk1"]
l co1/pk1 < []
s bytes < ["co1/pk1"]
s strings < ["co2/pk1" "co2/pk2"]
`)
}
开发者ID:fabxc,项目名称:govendor,代码行数:23,代码来源:context_test.go

示例15: TestTagList15

func TestTagList15(t *testing.T) {
	g := gt.New(t)
	defer g.Clean()

	g.Setup("co1/pk1",
		gt.File("a.go", "co2/pk1/pk2"),
		gt.File("a_test.go", "testing", "co2/pk1", "bytes"),
		gt.FileBuild("b.go", "appengine", "encoding/binary"),
	)
	g.Setup("co2/pk1",
		gt.File("a.go", "encoding/csv"),
	)
	g.Setup("co2/pk1/pk2",
		gt.File("a.go", "strings"),
	)
	g.In("co1")
	c := ctx15(g)
	c.IgnoreBuild("test appengine")

	list(g, c, "co1 list", `e co2/pk1/pk2 < ["co1/pk1"]
l co1/pk1 < []
s strings < ["co2/pk1/pk2"]
`)
}
开发者ID:kouhin,项目名称:govendor,代码行数:24,代码来源:context_test.go


注:本文中的github.com/kardianos/govendor/internal/gt.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。