EDIT: As rustyx said in the comment, this is a deprecated approach and you might want to consider newer ones
You can do without the go.mod
if your GOROOT
and GOPATH
environment variables are setted correctly
To do so, you can refer to
What should be the values of GOPATH and GOROOT?
Also, you need to ensure that your IDE/text editor also recognize those two variables.
Note: In the case of an IDE (such as Goland), you might need to set it up manually. In the case of a text editor (ex: vscode), you can simply reload your project and it should do the trick.
Once this is done, you can validate that the content of your $GOPATH/github.com/go-sql-driver/mysql/ is present. If not, you can rerun your go get -u github.com/go-sql-driver/mysql
command, reload your editor, and you should be alright