1. Check uninitialized map
For example,
var myMap map[int]int
myMap[0]=1
Obviously, there will be a panic, but I can’t find a way to auto-detect the problem. I have tried some tools like go-vet and golangci-lint. But they don’t work.
2. Check SQL spell
Furthermore, I also encountered another problem.
sqlStr := fmt.Sprintf("INSERT INTO user_table (id, region, status) VALUES (?, ?, ?)")
Here I want to insert three fields into the “user_table” table, so there are three “‘?’” as placeholders after it. The problem is, sometimes I need to insert ten or even more fields. And I will also frequently modify this statement. This will result in changes in the quantity of ‘?’, which may be inconsistent with the field quantity.
Is there a method that can help me automatically check for SQL spelling issues in my code.
If anyone could give me any advice, I would be very grateful