31 lines
412 B
Go
31 lines
412 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) != 2 {
|
|
fmt.Printf("Usage: %s URL\n", filepath.Base(os.Args[0]))
|
|
return
|
|
}
|
|
|
|
URL := os.Args[1]
|
|
data, err := http.Get(URL)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
} else {
|
|
defer data.Body.Close()
|
|
_, err := io.Copy(os.Stdout, data.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
}
|
|
}
|