How to deal with the problem when using air to realize hot overload

Time:2021-7-23

staycourseThe following errors will appear when you directly execute air according to the tutorial,

$ air

  __    _   ___  
 / /\  | | | |_) 
/_/--\ |_| |_| \_ v1.12.1 // live reload for Go apps, with Go1.14.0
watching .
!exclude tmp
building...
go: cannot find main module, 

It needs to be done firstgo mod init, and then executeair
In MAC environment, when air is hot overloaded, it will pop up

How to deal with the problem when using air to realize hot overload

Method 1: close the firewall

How to deal with the problem when using air to realize hot overload

Method 2: change the listening address to 127.0.0.1

Because the code in the tutorial is

http.ListenAndServe(":3000", nil)

Need to be changed to

http.ListenAndServe("127.0.0.1:3000", nil)

At this time, this dialog box will not pop up repeatedly, because 127.0.0.1 is a local virtual network card, which can only be accessed locally, but not by remote computers, so there is no need to go through the firewall at all

Method 3: sign vscodes with self built certificate

Failed. No hammer

This work adoptsCC agreementReprint must indicate the author and the link of this article