Install github.com/mattn/go-sqlite3 on Windows

This blog will show how to use a go library mattn/go-sqlite3: sqlite3 driver for go using database/sql (github.com) on Microsoft Windows . At first, if you go get a library. I will show an error about gcc

go get github.com/mattn/go-sqlite3
# github.com/mattn/go-sqlite3
exec: "gcc": executable file not found in %PATH%

However using it on a Windows PC/Laptop would require some step to setup a gcc by Installing GCC from here http://tdm-gcc.tdragon.net/download, After the download is finished (I prefer x64 version), the setup  steps are as follows:

  • Run tdm64-gcc-<yourversion>.exe, If UAC Pop-up appeared - Click Yes
  • Create ENV
  • Select 32-bit and 64-bit
  • Default Path
  • Select which component to install (Default)
  • follow the steps and wait to finish

Test

  • Test GCC command
  • Test Get Package
go mod init example.com/sqlite
go get github.com/mattn/go-sqlite3
  • Create Sample Project

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.