I am writing a simple web app in golang: golang http main.go server, with vscode user mode invocation
the server snippet:
package mainimport ("fmt""net/http")func helloWorldPage(w http.ResponseWriter, r *http.Request){ fmt.Fprint(w, "Hello world!")}func main(){ http.HandleFunc("/", helloWorldPage) http.ListenAndServe("", nil)}
The problem is invocations from terminal via vscode (or simple user mode for that matter) immediately terminates without serving at default port 80.
drainbamage@LAPTOP-KPETF9CD:~/dev/portfolio$ go versiongo version go1.22.3 linux/amd64drainbamage@LAPTOP-KPETF9CD:~/dev/portfolio$ go run main.go <--- terminates without hosting.drainbamage@LAPTOP-KPETF9CD:~/dev/portfolio$
However... if I run the same command in root mode, it works as expected:
drainbamage@LAPTOP-KPETF9CD:~/dev/portfolio$ sudo su[sudo] password for drainbamage:root@LAPTOP-KPETF9CD:/home/drainbamage/dev/portfolio# go run main.go <--- working as expected.^Csignal: interruptroot@LAPTOP-KPETF9CD:/home/drainbamage/dev/portfolio#
Tried
go version
command works just fine in both root and user mode.- Its just http serving which it is just not able to do, I tried this (not exactly my problem, actually opposite, but tried: https://forum.golangbridge.org/t/go-doesnt-work-in-root-mode/27340/3)
- my guess is, given that it's working in root mode, it might be lacking some permissions? I am new to wsl environment, so I think it could be related to that.
Expected
- Expecting same result as of root mode in normal mode.