在Go 1.6之前, 内置的map类型是部分goroutine安全的,并发的读没有问题,并发的写可能有问题。自go 1.6之后, 并发地读写map会报错,这在一些知名的开源库中都存在这个问题,所以go 1.9之前的解决方案是额外绑定一个锁,封装成一个新的struct或者单独使用锁都可以。
官网解决方案 Some systems are hard coded to not use proxies for localhost traffic, so when you connect to http://localhost/ it doesn’t show up in Charles. The workaround is to connect to localhost.charlesproxy.com/ instead. This points to the IP address 127.0.0.1, so it should work identically to localhost, but with the advantage that it will go through Charles. This will work whether or not Charles is running or you’re using Charles. If you use a different port, such as 8080, just add that as you usually would, e.g. localhost.charlesproxy.com:8080. You can also put anything in front of that domain, e.g. myapp.localhost.charlesproxy.com, which will also always resolve to 127.0.0.1. Alternatively you can try adding a ‘.’ after localhost, or replace localhost with the name of your machine, or use your local link IP address (eg. 192.168.1.2). If Charles is running and you’re using Charles as your proxy, you can also use local.charles as an alternative for localhost. Note that this only works when you’re using Charles as your proxy, so the above approaches are preferred, unless you specifically want requests to fail if not using Charles