code: func setFilePermissions(path string, user, group, mode string) error {
  	var err error
  	uid, gid := os.Getuid(), os.Getgid()
  
  	if user != "" {
  		if uid, err = strconv.Atoi(user); err == nil {
  			goto GROUP
  		}
  
  		// Try looking up the user by name
  		u, err := osuser.Lookup(user)
  		if err != nil {
  			return fmt.Errorf("failed to look up user %s: %v", user, err)
  		}
  		uid, _ = strconv.Atoi(u.Uid)
  	}
  
  GROUP:
  	if group != "" {
  		if gid, err = strconv.Atoi(group); err != nil {
  			return fmt.Errorf("invalid group specified: %v", group)
  		}
  	}
  	if err := os.Chown(path, uid, gid); err != nil {
  		return fmt.Errorf("failed setting ownership to %d:%d on %q: %s",
  			uid, gid, path, err)
  	}
  
  	if mode != "" {
  		mode, err := strconv.ParseUint(mode, 8, 32)
  		if err != nil {
  			return fmt.Errorf("invalid mode specified: %v", mode)
  		}
  		if err := os.Chmod(path, os.FileMode(mode)); err != nil {
  			return fmt.Errorf("failed setting permissions to %d on %q: %s",
  				mode, path, err)
  		}
  	}
  
  	return nil
  }
docs: // setFilePermissions handles configuring ownership and permissions
  // settings on a given file. All permission/ownership settings are
  // optional. If no user or group is specified, the current user/group
  // will be used. Mode is optional, and has no default (the operation is
  // not performed if absent). User may be specified by name or ID, but
  // group may only be specified by ID.