It does not work because your foobar.go
source file is not in a directory called foobar
. go build
and go install
try to match directories, not source files.
- Set
$GOPATH
to a valid directory, e.g.export GOPATH="$HOME/go"
- Move
foobar.go
to$GOPATH/src/foobar/foobar.go
and building should work just fine.
Additional recommended steps:
- Add
$GOPATH/bin
to your$PATH
by:PATH="$GOPATH/bin:$PATH"
- Move
main.go
to a subfolder of$GOPATH/src
, e.g.$GOPATH/src/test
go install test
should now create an executable in$GOPATH/bin
that can be called by typingtest
into your terminal.
Related Posts:
- Contains method for a slice
- How to delete an element from a Slice in Golang
- strconv.Atoi() throwing error when given a string
- Is there a foreach loop in Go?
- How to uninstall Go?
- GO language: fatal error: all goroutines are asleep – deadlock
- What is a rune?
- How to install pip with Python 3?
- Relative imports – ModuleNotFoundError: No module named x
- Relative imports – ModuleNotFoundError: No module named x
- “pip install unroll”: “python setup.py egg_info” failed with error code 1
- “pip install unroll”: “python setup.py egg_info” failed with error code 1
- How can I solve “java.lang.NoClassDefFoundError”?
- What is __init__.py for?
- What is __init__.py for?
- beyond top level package error in relative import
- What is a build tool?
- What is an idiomatic way of representing enums in Go?
- beyond top level package error in relative import
- Virustotal Trapmine suspicious.low.ml.score
- Error – Android resource linking failed (AAPT2 27.0.3 Daemon #0)
- Error – Android resource linking failed (AAPT2 27.0.3 Daemon #0)
- ModuleNotFoundError: No module named ‘sklearn’
- beyond top level package error in relative import
- ModuleNotFoundError: No module named ‘sklearn’
- How is “mvn clean install” different from “mvn install”?
- Still getting warning : Configuration ‘compile’ is obsolete and has been replaced with ‘implementation’
- What is a Python egg?
- Python error: AttributeError: ‘module’ object has no attribute
- Java Package Does Not Exist Error
- Python 3: ImportError “No Module named Setuptools”
- MINGW64 “make build” error: “bash: make: command not found”
- What’s the difference between a Python module and a Python package?
- Find the version of an installed npm package
- How to fix “Attempted relative import in non-package” even with __init__.py
- Extracting substrings in Go
- Golang package is not in GOROOT (/usr/local/go/src/packageName)
- Download TS files from video stream
- How to load modules from gitlab subgroup?
- Gradle does not find tools.jar
- How to import local packages in go?
- How to fix “Attempted relative import in non-package” even with __init__.py
- node_modules/rxjs/internal/types.d.ts(81,44): error TS1005: ‘;’ expected error after installation of Angular 6
- What is the difference between –save and –save-dev?
- How to import local packages without gopath
- error: This is probably not a problem with npm. There is likely additional logging output above
- Can’t import my own modules in Python
- How to check if a file exists in Go?
- Visual Studio: The Operation could not be completed. The parameter is incorrect
- How to measure test coverage in Go
- com.android.ide.common.process.ProcessException: Failed to execute aapt! What can I do?
- How to set GOPRIVATE environment variable
- Is there a queue implementation?
- What’s the difference between a Python module and a Python package?
- Error in contrib.url(repos, “source”) in R trying to use CRAN without setting a mirror Calls: install.packages -> contrib.url Execution halted
- g++ output: file not recognized: File format not recognized
- How to print struct variables in console?
- How to find out which package version is loaded in R?
- How to unload a package without restarting R
- How to make rpm auto install dependencies
- How do I update a Python package?
- Import cycle not allowed
- What is the difference between require() and library()?
- Command not found go — on Mac after installing Go
- cannot download, $GOPATH not set
- How can I remove a package from Laravel using PHP Composer?
- “Python version 2.7 required, which was not found in the registry” error when attempting to install netCDF4 on Windows 8
- Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven
- What is the difference between gmake and make?