Trying GO with SQL Server

Not the batch separator, but the GO language.

I’m always interested in learning new things, and GO has been one of those items that I’ve wanted to look at and see how it works. This is a big language at Google and

I saw a new blog from Mat Hayward-Hill on Golang (Go) and decided to make a quick test. After all, he had the code. I first installed the Go language, which was simple. I then added a variable according to the blog and the extension to VSCode.

From there, I copied his code and tried it. Hello World worked fine, but I had a couple issues with the SQL connection.

First, I don’t have default instances, just named ones. The connection string was:

condb, errdb := sql.Open("mssql", "server=localhost\SQL2016;user id=sa;password=SA_PASSWORD=yourStrong(!)Password;")

However, I had to escape the backslash. VSCode showed this to be an issue, so I tried a second one to clean things up. This worked fine.

condb, errdb := sql.Open("mssql", "server=localhost\\SQL2016;user id=sa;password=SA_PASSWORD=yourStrong(!)Password;")

The next thing was the entire password string, including the second equals sign, needs to be your pwd. I connected to SQL 2016 on Win, and once I removed the stuff after the second =, I connected and got the version back.

The Go Language

Go was created by Google and is something of an evolution of C, but with some of the ease of Python. It’s apparently good for things like network and web servers where concurrency matters. More of a systems programming language, not one for GUI or desktop apps.

Who uses it? Quite a few well known sites. Google does, Kubernetes (the container company), YouTube (technically Google as well), 99Designs, Adobe, Bitbucket, Pinterest, and more. It seems to have more popularity than I’d expect, but I don’t examine the language breakdowns often and I’m sure it’s just one of many languages used at these companies.

Still, it was neat to try a new language. Now to try a few tutorials over at golang.org.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s