code: func WriteBytesToFileWithPermission(pth string, fileCont []byte, perm os.FileMode) error {
  	if pth == "" {
  		return errors.New("No path provided")
  	}
  
  	var file *os.File
  	var err error
  	if perm == 0 {
  		file, err = os.Create(pth)
  	} else {
  		// same as os.Create, but with a specified permission
  		//  the flags are copy-pasted from the official
  		//  os.Create func: https://golang.org/src/os/file.go?s=7327:7366#L244
  		file, err = os.OpenFile(pth, os.O_RDWR|os.O_CREATE|os.O_TRUNC, perm)
  	}
  	if err != nil {
  		return err
  	}
  	defer func() {
  		if err := file.Close(); err != nil {
  			log.Println(" [!] Failed to close file:", err)
  		}
  	}()
  
  	if _, err := file.Write(fileCont); err != nil {
  		return err
  	}
  
  	return nil
  }
docs: // WriteBytesToFileWithPermission ...