When using Goland it is very useful to get SQL syntax highlight and autocompletion based on my connected datasources. Unfortunately this only seems to work when I'm using the standard Go sql package and does not work when I use custom packages that effectively wrap the sql package calls. I was wondering if it's possible to tell Goland that specific functions / parameters are actually SQL queries / SQL statements.
Here's an example of Goland allowing SQL completion for methods on sql.DB struct vs not allowing completion on custom query.ReadOnlyDB struct:
Currently, you can specify //language=SQL
comment before the statement:
package main
import "fmt"
func main() {
//language=SQL
str := "SELECT USERNAME FROM EXAMPLE"
fmt.Println(str)
}
There are a few tickets to improve SQL highlighting in GoLand and you can follow them: