如何在Windows上安装go-sql-driver

I am trying to install go-sql-driver on Windows Vista but I am having problems with GOPATH.

I installed git as suggested and added GOPATH as a new user environment in Windows with path C:/users/A/desktop/go.

I ran go get github.com/go-sql-driver/mysql in the command line but it gives me this error:

C:\>go get github.com/go-sql-driver/mysql
go: missing Git command. See http://golang.org/s/gogetcmd
package github.com/go-sql-driver/mysql: exec: "git": executable file not found in %PATH%

When I go look at http://golang.org/s/gogetcmd it merely says download git. But it is already downloaded in my machine.

I also went ahead and created a new environement variable for PATH and set its path to the directory where git was installed but that did not help either.

What am I doing wrong?

Download the Windows version of Git from http://git-scm.com/downloads.

Run the downloaded executable file, currently Git-1.8.3-preview20130601.exe, which will start a Git Setup wizard to install Git.

Check Git Setup Options

  • Run Git from the Windows Command Prompt
  • Checkout as-is, commit Unix-style line endings

Check the installation by running:

C:\>git --version
git version 1.8.3.msysgit.0

Make sure Git is in the %PATH% environment variable and ensure Git is installed. If you cannot run git --version in the command prompt, then the Git binary directory isn't listed in your %PATH%. Fix this by adding Git to the path, close the command prompt, and run git --version in a new command prompt. If you're still having issues, then you might be having other problems.

Install the GIT BASH desktop app in your Windows PC. The download link is here. Once installed, open the shell and type:

go get -u github.com/go-sql-driver/mysql

This will install driver for Golang's MySQL database package