I have a question about map in go language.
I want to handle the clients (http
) and save some of their information using map
(key (client IP) value pair) ...
http
handle each http client using a new thread, so I think changing (add, delete, edit) the map
data will be unsafe ... Is my action safe ?
package main
import (
"net/http"
)
func main() {
var clientsData map[string]string
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
// Is this map adding, safe or i have to use thread lock (mutex or ...) ?
clientsData[request.RemoteAddr] = ...
})
http.ListenAndServe("127.0.0.10:8090", nil)
}