Created
          January 17, 2018 16:40 
        
      - 
      
 - 
        
Save mlbright/7d65a5bbd3b29a6a2886da8f49d0e986 to your computer and use it in GitHub Desktop.  
    Compare golang's filepath.Split and filepath.Dir
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package main | |
| import ( | |
| "fmt" | |
| "path/filepath" | |
| ) | |
| func main() { | |
| paths := []string{ | |
| "/home/arnie/amelia.jpg", | |
| "/mnt/photos/", | |
| "/mnt/photos", | |
| "mnt/photos", | |
| "rabbit.jpg", | |
| "/usr/local//go", | |
| ".", | |
| "/", | |
| } | |
| fmt.Println("On Unix:") | |
| for _, p := range paths { | |
| dir, file := filepath.Split(p) | |
| fmt.Printf("input: %q\n\tdir: %q\n\tfilepath.Dir: %q\n\tfile: %q\n", p, dir, filepath.Dir(p), file) | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment