10

I want to use Go, the programming language on Windows using MSYS2.
Which package should I use and how to avoid errors like:

package bufio: unrecognized import path "bufio"
package bytes: unrecognized import path "bytes"
package crypto: unrecognized import path "crypto"
package crypto/des: unrecognized import path "crypto/des"
package crypto/hmac: unrecognized import path "crypto/hmac"
package crypto/md5: unrecognized import path "crypto/md5"
package crypto/rand: unrecognized import path "crypto/rand"
package crypto/rc4: unrecognized import path "crypto/rc4"
package crypto/sha256: unrecognized import path "crypto/sha256"
package crypto/tls: unrecognized import path "crypto/tls"
package crypto/x509: unrecognized import path "crypto/x509"
package encoding/base64: unrecognized import path "encoding/base64"
package encoding/binary: unrecognized import path "encoding/binary"
package encoding/hex: unrecognized import path "encoding/hex"
package encoding/json: unrecognized import path "encoding/json"
package encoding/xml: unrecognized import path "encoding/xml"
package errors: unrecognized import path "errors"
package fmt: unrecognized import path "fmt"
package io: unrecognized import path "io"
package os: unrecognized import path "os"
package path/filepath: unrecognized import path "path/filepath"
package runtime: unrecognized import path "runtime"
package strconv: unrecognized import path "strconv"
package strings: unrecognized import path "strings"
package sync: unrecognized import path "sync"
package time: unrecognized import path "time"
package os/exec: unrecognized import path "os/exec"
package syscall: unrecognized import path "syscall"
package io/ioutil: unrecognized import path "io/ioutil"
package regexp: unrecognized import path "regexp"
package hash: unrecognized import path "hash"
package net: unrecognized import path "net"
package sync/atomic: unrecognized import path "sync/atomic"
package unsafe: unrecognized import path "unsafe"
package hash/crc32: unrecognized import path "hash/crc32"
package reflect: unrecognized import path "reflect"
package unicode/utf16: unrecognized import path "unicode/utf16"
package unicode: unrecognized import path "unicode"
package unicode/utf8: unrecognized import path "unicode/utf8"
package math: unrecognized import path "math"
package net/http: unrecognized import path "net/http"
package net/http/httputil: unrecognized import path "net/http/httputil"
package net/url: unrecognized import path "net/url"
package path: unrecognized import path "path"
package sort: unrecognized import path "sort"
package text/template: unrecognized import path "text/template"
package log: unrecognized import path "log"
package os/signal: unrecognized import path "os/signal"
qwertzguy
  • 15,699
  • 9
  • 63
  • 66

1 Answers1

20

Install Go lang with: pacman -S mingw-w64-x86_64-go

Configure env variables:

export GOROOT=/mingw64/lib/go
export GOPATH=/mingw64

Start using Go :)

go get will download (in mingw64/src), compile and make binaries available on your path (/mingw64/bin)

qwertzguy
  • 15,699
  • 9
  • 63
  • 66
  • These days, one should not set `GOROOT` explicitly for long time ago. – kostix May 13 '16 at 14:12
  • I then wonder, if you unset `GOROOT` and run `go env`, does it display the correct (built-in) value for `GOROOT`? – kostix May 13 '16 at 14:20
  • 4
    Yea, unfortunately on MSYS2, the default value for GOROOT is incorrect, and even `go env` doesn't run in that case :( – qwertzguy May 14 '16 at 13:39
  • 1
    unfortunately after doing all this, go does not work, the binary is not there – avp Mar 23 '18 at 21:07
  • If I follow your advise there is no go binary it seems. Even `find` can't see any. – erikbstack May 08 '18 at 14:22
  • 3
    After installing `mingw-w64-x86_64-go`, `GOROOT` was set to the correct path for me. – Nikolai Jun 04 '18 at 10:11
  • 1
    This also worked for me. I `export PATH="${PATH}:${GOROOT}/bin"` and `export GOPATH=/mingw64`. Restarted my terminal and it worked. – FilBot3 Nov 01 '19 at 14:29
  • 3
    After `pacman -S mingw-w64-x86_64-go`, the old environment is still running in your terminal. Close that session, start a new one, and run `go version`. Just worked for me. – Caleb Gray Jun 24 '20 at 23:31