I'm very new to system programming.
I have a Go program which uses net/http
and starts an http server.
When I build a Windows binary and tried on a target Windows machine, nothing worked except Printf
s before it starts the server.
As soon as I installed Go on the target Windows machine, everything started working!
Here is my program:
package main
import (
"fmt"
"log"
"os/exec"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there @%s!", r.URL.Path[1:])
}
func main() {
path, err := exec.LookPath("go")
if err != nil {
log.Fatal("Go is not your fortune :|")
}
fmt.Printf("Go is available at %s\n", path)
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
If go
doesn't build all the dependencies with its program then how do I do it? If it does, why it is not working?
Does target systems have to have go
installed prior to run any Go programs?
Please help! Thanks.