我有少量不相关的文件(它们不是模块或项目的一部分),只是各种草图和注释。
如何一次收集它们,而无需每次明确指定需要编译的内容?
go run .
# _/mnt/library/projects/hck/Go
./listen.go:12:6: main redeclared in this block
previous declaration at ./array.go:7:6
go build .
# _/home/Sharlatan/Projects/hck/Go
./listen.go:12:6: main redeclared in this block
previous declaration at ./array.go:7:6
/array.go/
package main
import (
"fmt"
)
func main() {
var a1 [10]int
a2 := [...]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
fmt.Println(a1)
fmt.Println(a2)
}
/listen.go/
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there!")
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8181", nil)
}