Go Lang Firewall


(Hardeen L) #1

Dear Sirs,

How to remove this firewall every time i run golang web app.

Capture

Thanks

Trainers


(Robert Sung Wook Shin) #2

If you are playing with localhost only,
Could you try set Listening address from :80 to 127.0.0.1:80 in your source?

Then The Windows firewall will not ask it to you, maybe :smile:


(Hardeen L) #3

Thanks, but still showing dud


(Robert Sung Wook Shin) #4

Can you share your code?


(Hardeen L) #5
		package main

	import (
	  "html/template"
	  "log"
	  "net/http"
	  "time"
	)

	type PageVariables struct {
		Date         string
		Time         string
	}

	func main() {
		http.HandleFunc("/", HomePage)
		log.Fatal(http.ListenAndServe(":8080", nil))
	}

	func HomePage(w http.ResponseWriter, r *http.Request){

		now := time.Now() // find the time right now
		HomePageVars := PageVariables{ //store the date and time in a struct
		  Date: now.Format("02-01-2006"),
		  Time: now.Format("15:04:05"),
		}

		t, err := template.ParseFiles("homepage.html") //parse the html file homepage.html
		if err != nil { // if there is an error
		  log.Print("template parsing error: ", err) // log it
		}
		err = t.Execute(w, HomePageVars) //execute the template and pass it the HomePageVars struct to fill in the gaps
		if err != nil { // if there is an error
		  log.Print("template executing error: ", err) //log it
		}
	}

(Denis) #6

Did you attempt to do what edp1096 suggested?

Change
log.Fatal(http.ListenAndServe(":8080", nil))
to
log.Fatal(http.ListenAndServe("127.0.0.1:8080", nil))


(Hardeen L) #7

still showing sir. when i compile that firewall will come out


(Norbert Melzer) #8

The easiest way is to use go build instead and run the created binary, then you can add an exclusion rule, and as long as name and path of the binary don’t change windows won’t ask again.

If there is a way to fix go runs output path, that would work as well.


(Robert Sung Wook Shin) #9

I tried to create a repo with your code but, could not reproduce firewall appearance.

Could you try to build below repo?


(Hardeen L) #10

Hello Mr. edp1096, i tried your sample it will not ask the firewall. why? can you explain me please. This exactly i’m asking. Thank you.


(Robert Sung Wook Shin) #11

Hello @n_oandasan, please see @metonymyqt’s mention.


(Hardeen L) #12

thank you so much experts