Created
September 29, 2018 19:39
-
-
Save Ethan-Arrowood/9cbeafff8bfe4cfff49018d83564c9d4 to your computer and use it in GitHub Desktop.
First implementation of a file copy program written in Go
This file contains 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 ( | |
"io/ioutil" | |
"log" | |
"os" | |
) | |
func fcopy(src, dst string) { | |
content, err := ioutil.ReadFile(src) | |
if err != nil { | |
log.Fatal(err) | |
} | |
err = ioutil.WriteFile(dst, content, 0777) | |
if err != nil { | |
log.Fatal(err) | |
} | |
log.Printf("Successfully copied contens of %s to %s", src, dst) | |
} | |
func main() { | |
if l := len(os.Args); l != 3 { | |
log.Printf("Usage: fcopy <src file> <dst file>") | |
} else { | |
fcopy(os.Args[1], os.Args[2]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment