github.com/sdboyer/gps@v0.16.3/strip_vendor.go (about)

     1  //+build !windows
     2  
     3  package gps
     4  
     5  import "os"
     6  
     7  func stripVendor(path string, info os.FileInfo, err error) error {
     8  	if info.Name() == "vendor" {
     9  		if _, err := os.Lstat(path); err == nil {
    10  			if (info.Mode() & os.ModeSymlink) != 0 {
    11  				realInfo, err := os.Stat(path)
    12  				if err != nil {
    13  					return err
    14  				}
    15  				if realInfo.IsDir() {
    16  					return os.Remove(path)
    17  				}
    18  			}
    19  			if info.IsDir() {
    20  				return removeAll(path)
    21  			}
    22  		}
    23  	}
    24  
    25  	return nil
    26  }