Muhammad Hafid

Blog Belajar Python atau Django

Muhammad Hafid

Tugas kita itu adalah bukan untuk berhasil, tugas kita adalah untuk mencoba, karena di dalam mencoba itulah kita menemukan dan belajar membangun kesempatan untuk berhasil.

Error Message Go Uunrecognized import path

Pernah mengalami error golang seperti pada gambar dibawah ini ? biasanya error semacam ini terjadi dikarenakan konfigurasi GOPATH dan GOROOT. Sebelum kita bicara fix problematikanya sekarang coba kalian cek go env kalian, apakah sudah seperti punya saya dibawah ini :

hafid@mhafid:~$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"

GOPATH="/home/hafid/go"

GORACE=""

GOROOT="/usr/local/go"

GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build072221980=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
Saya menggunakan Linux Ubuntu dan golang versi 1.8 ya guys. Disana coba perhatikan GOPATH dan GOROOT. gopath dan goroot tidak boleh sama, karena secara persepsi gopath itu tempat kita menyimpan source development go, sedangkan goroot adalah untuk membaca engine golangnya agar script yang dituliskan dengan bahasa golang yang disimpan didalam GOPATH bisa di execute.

Apabila kalian error seperti ini dibawah ini :
package crypto/subtle: unrecognized import path "crypto/subtle" (import path does not begin with hostname)
package encoding/gob: unrecognized import path "encoding/gob" (import path does not begin with hostname)
package encoding/hex: unrecognized import path "encoding/hex" (import path does not begin with hostname)
package log: unrecognized import path "log" (import path does not begin with hostname)
package math/rand: unrecognized import path "math/rand" (import path does not begin with hostname)
package mime: unrecognized import path "mime" (import path does not begin with hostname)
package mime/multipart: unrecognized import path "mime/multipart" (import path does not begin with hostname)
package net/mail: unrecognized import path "net/mail" (import path does not begin with hostname)
package net/smtp: unrecognized import path "net/smtp" (import path does not begin with hostname)
package net/textproto: unrecognized import path "net/textproto" (import path does not begin with hostname)
package path: unrecognized import path "path" (import path does not begin with hostname)
package regexp: unrecognized import path "regexp" (import path does not begin with hostname)
package runtime: unrecognized import path "runtime" (import path does not begin with hostname)
package net/http: unrecognized import path "net/http" (import path does not begin with hostname)
package net/url: unrecognized import path "net/url" (import path does not begin with hostname)
package html/template: unrecognized import path "html/template" (import path does not begin with hostname)
package net: unrecognized import path "net" (import path does not begin with hostname)
package flag: unrecognized import path "flag" (import path does not begin with hostname)
package os/exec: unrecognized import path "os/exec" (import path does not begin with hostname)
package os/signal: unrecognized import path "os/signal" (import path does not begin with hostname)
package syscall: unrecognized import path "syscall" (import path does not begin with hostname)
package math: unrecognized import path "math" (import path does not begin with hostname)
package runtime/debug: unrecognized import path "runtime/debug" (import path does not begin with hostname)
package runtime/pprof: unrecognized import path "runtime/pprof" (import path does not begin with hostname)
package sort: unrecognized import path "sort" (import path does not begin with hostname)
package go/ast: unrecognized import path "go/ast" (import path does not begin with hostname)
package go/parser: unrecognized import path "go/parser" (import path does not begin with hostname)
package go/token: unrecognized import path "go/token" (import path does not begin with hostname)
package net/http/fcgi: unrecognized import path "net/http/fcgi" (import path does not begin with hostname)
package text/template: unrecognized import path "text/template" (import path does not begin with hostname)
package unicode: unrecognized import path "unicode" (import path does not begin with hostname)
Kalian harus perbaiki, untuk settingan go env GoPATH dan GoROOT saya adalah :
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOROOT/bin
Semoga bermanfaat. 
Labels: Go

Thanks for reading Error Message Go Uunrecognized import path . Please share...!

0 Comment for "Error Message Go Uunrecognized import path"

Back To Top