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


Golang gt.File函數代碼示例

本文整理匯總了Golang中github.com/kardianos/govendor/internal/gt.File函數的典型用法代碼示例。如果您正苦於以下問題:Golang File函數的具體用法?Golang File怎麽用?Golang File使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了File函數的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: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例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.File函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。