Go Lang Firewall

Dear Sirs,

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

Capture

Thanks

Trainers

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:

1 Like

Thanks, but still showing dud

Can you share your code?

		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
		}
	}

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))

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

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.

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

Could you try to build below repo?

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.

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

thank you so much experts

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.