Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Go lang with MSYS2

Tags:

go

pacman

msys2

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"
like image 906
qwertzguy Avatar asked May 12 '16 22:05

qwertzguy


1 Answers

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)

like image 101
qwertzguy Avatar answered Sep 30 '22 16:09

qwertzguy