本文整理汇总了Golang中github.com/constabulary/gb/fileutils.RemoveAll函数的典型用法代码示例。如果您正苦于以下问题:Golang RemoveAll函数的具体用法?Golang RemoveAll怎么用?Golang RemoveAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RemoveAll函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Checkout
func (h *hgrepo) Checkout(branch, tag, revision string) (WorkingCopy, error) {
if !atMostOne(tag, revision) {
return nil, fmt.Errorf("only one of tag or revision may be supplied")
}
dir, err := mktmp()
if err != nil {
return nil, err
}
args := []string{
"clone",
h.url,
dir,
"--noninteractive",
}
if branch != "" {
args = append(args, "--branch", branch)
}
if err := runOut(os.Stderr, "hg", args...); err != nil {
fileutils.RemoveAll(dir)
return nil, err
}
if revision != "" {
if err := runOut(os.Stderr, "hg", "--cwd", dir, "update", "-r", revision); err != nil {
fileutils.RemoveAll(dir)
return nil, err
}
}
return &HgClone{
workingcopy{
path: dir,
},
}, nil
}
开发者ID:arya,项目名称:gvt,代码行数:35,代码来源:repo.go
示例2: Destroy
func (w workingcopy) Destroy() error {
if err := fileutils.RemoveAll(w.path); err != nil {
return err
}
parent := filepath.Dir(w.path)
return cleanPath(parent)
}
开发者ID:arya,项目名称:gvt,代码行数:7,代码来源:repo.go
示例3: downloadDependency
func downloadDependency(dep vendor.Dependency) error {
log.Printf("fetching %s", dep.Importpath)
repo, _, err := vendor.DeduceRemoteRepo(dep.Importpath, rbInsecure)
if err != nil {
return fmt.Errorf("dependency could not be processed: %s", err)
}
wc, err := repo.Checkout("", "", dep.Revision)
if err != nil {
return fmt.Errorf("dependency could not be fetched: %s", err)
}
dst := filepath.Join(vendorDir(), dep.Importpath)
src := filepath.Join(wc.Dir(), dep.Path)
if _, err := os.Stat(dst); err == nil {
if err := fileutils.RemoveAll(dst); err != nil {
return fmt.Errorf("dependency could not be deleted: %v", err)
}
}
if err := fileutils.Copypath(dst, src); err != nil {
return err
}
if err := wc.Destroy(); err != nil {
return err
}
return nil
}
开发者ID:arya,项目名称:gvt,代码行数:29,代码来源:restore.go
示例4: cleanPath
func cleanPath(path string) error {
if files, _ := ioutil.ReadDir(path); len(files) > 0 || filepath.Base(path) == "vendor" {
return nil
}
parent := filepath.Dir(path)
if err := fileutils.RemoveAll(path); err != nil {
return err
}
return cleanPath(parent)
}
开发者ID:arya,项目名称:gvt,代码行数:10,代码来源:repo.go
示例5: downloadDependency
func downloadDependency(dep vendor.Dependency, vendorDir string, recursive bool) error {
if recursive {
log.Printf("fetching recursive %s", dep.Importpath)
} else {
log.Printf("fetching %s", dep.Importpath)
}
repo, _, err := vendor.DeduceRemoteRepo(dep.Importpath, rbInsecure)
if err != nil {
return fmt.Errorf("dependency could not be processed: %s", err)
}
// We can't pass the branch here, and benefit from narrow clones, as the
// revision might not be in the branch tree anymore. Thanks rebase.
wc, err := repo.Checkout("", "", dep.Revision)
if err != nil {
return fmt.Errorf("dependency could not be fetched: %s", err)
}
dst := filepath.Join(vendorDir, dep.Importpath)
src := filepath.Join(wc.Dir(), dep.Path)
if _, err := os.Stat(dst); err == nil {
if err := fileutils.RemoveAll(dst); err != nil {
return fmt.Errorf("dependency could not be deleted: %v", err)
}
}
if err := fileutils.Copypath(dst, src); err != nil {
return err
}
if err := wc.Destroy(); err != nil {
return err
}
// Check for for manifests in dependencies
man := filepath.Join(dst, "vendor", "manifest")
venDir := filepath.Join(dst, "vendor")
if _, err := os.Stat(man); err == nil {
m, err := vendor.ReadManifest(man)
if err != nil {
return fmt.Errorf("could not load manifest: %v", err)
}
var errors uint32
for _, d := range m.Dependencies {
if err := downloadDependency(d, venDir, true); err != nil {
log.Printf("%s: %v", d.Importpath, err)
atomic.AddUint32(&errors, 1)
}
}
}
return nil
}
开发者ID:jzt,项目名称:gvt,代码行数:53,代码来源:restore.go
示例6: TestManifest
func TestManifest(t *testing.T) {
root := mktemp(t)
defer fileutils.RemoveAll(root)
mf := filepath.Join(root, "vendor")
// check that reading an non existant manifest
// does not return an error
m, err := ReadManifest(mf)
if err != nil {
t.Fatalf("reading a non existant manifest should not fail: %v", err)
}
// check that no manifest file was created
assertNotExists(t, mf)
// add a dep
m.Dependencies = append(m.Dependencies, Dependency{
Importpath: "github.com/foo/bar/baz",
Repository: "https://github.com/foo/bar",
Revision: "cafebad",
Branch: "master",
Path: "/baz",
})
// write it back
if err := WriteManifest(mf, m); err != nil {
t.Fatalf("WriteManifest failed: %v", err)
}
// check the manifest was written
assertExists(t, mf)
// remove it
m.Dependencies = nil
if err := WriteManifest(mf, m); err != nil {
t.Fatalf("WriteManifest failed: %v", err)
}
// check that no manifest file was removed
assertNotExists(t, mf)
}
开发者ID:torfuzx,项目名称:gb,代码行数:42,代码来源:manifest_test.go
示例7:
if strings.HasPrefix(i, d) {
return true
}
}
return false
}
dependencies := make([]vendor.Dependency, len(m.Dependencies))
copy(dependencies, m.Dependencies)
for _, d := range dependencies {
if !hasImportWithPrefix(d.Importpath) {
dep, err := m.GetDependencyForImportpath(d.Importpath)
if err != nil {
return fmt.Errorf("could not get get dependency: %v", err)
}
if err := m.RemoveDependency(dep); err != nil {
return fmt.Errorf("dependency could not be removed: %v", err)
}
if err := fileutils.RemoveAll(filepath.Join(ctx.Projectdir(), "vendor", "src", filepath.FromSlash(d.Importpath))); err != nil {
// TODO(dfc) need to apply vendor.cleanpath here to remove indermediate directories.
return fmt.Errorf("dependency could not be deleted: %v", err)
}
}
}
return vendor.WriteManifest(manifestFile(ctx), m)
},
}
开发者ID:torfuzx,项目名称:gb,代码行数:30,代码来源:purge.go
示例8:
}
branch, err := wc.Branch()
if err != nil {
return err
}
dep := vendor.Dependency{
Importpath: d.Importpath,
Repository: repo.URL(),
Revision: rev,
Branch: branch,
Path: extra,
}
if err := fileutils.RemoveAll(filepath.Join(vendorDir(), filepath.FromSlash(d.Importpath))); err != nil {
// TODO(dfc) need to apply vendor.cleanpath here to remove intermediate directories.
return fmt.Errorf("dependency could not be deleted: %v", err)
}
dst := filepath.Join(vendorDir(), filepath.FromSlash(dep.Importpath))
src := filepath.Join(wc.Dir(), dep.Path)
if err := fileutils.Copypath(dst, src); err != nil {
return err
}
if err := m.AddDependency(dep); err != nil {
return err
}
开发者ID:sekimura,项目名称:gvt,代码行数:30,代码来源:update.go
示例9: Destroy
func (w workingcopy) Destroy() error {
return fileutils.RemoveAll(w.path)
}
开发者ID:clawconduce,项目名称:gvt,代码行数:3,代码来源:repo.go
注:本文中的github.com/constabulary/gb/fileutils.RemoveAll函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论