How can the existing version of go be updated using the go install command?
I've done the following
$ go install golang.org/dl/go1.19.4#latest
go: downloading golang.org/dl v0.0.0-20221207214018-bd7282711064
$ go1.19.4 download
Downloaded 0.0% ( 16384 / 148931745 bytes) ...
Downloaded 9.2% ( 13647776 / 148931745 bytes) ...
Downloaded 36.2% ( 53870192 / 148931745 bytes) ...
Downloaded 61.8% ( 92028240 / 148931745 bytes) ...
Downloaded 87.4% (130137120 / 148931745 bytes) ...
Downloaded 100.0% (148931745 / 148931745 bytes)
Unpacking /home/gameveloster/sdk/go1.19.4/go1.19.4.linux-amd64.tar.gz ...
Success. You may now run 'go1.19.4'
$ which go1.19.4
/home/gameveloster/go/bin/go1.19.4
$ which go
/home/gameveloster/.go/bin/go
Is the final step to copy the newly downloaded go binary ~/go/bin/go1.19.4 to replace the existing ~/.go/bin/go?
Is there a special way to then clean up ~/go/bin/go1.19.4, or is simply deleting this binary sufficient?
The short answer is No you can't update the existing version of go.
First, you have to uninstall the currently installed version and then install a newer version.
Here is an easy solution,
To find the installation address run
where go
To uninstall, delete the given address of above,
sudo rm -rf [output of above command]
To check if you already remove go, run the below command; the system will prompt "command go not found"
go --version
Now install a newer version of go
wget https://go.dev/dl/go1.19.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz
Make sure that your PATH contains /usr/local/go/bin
export PATH=$PATH:/usr/local/go/bin
After that, you will need to restart your terminal for the change to take effect.
To check if you have installed Go successfully, run the below command.
go --version
Enjoy!
How can the existing version of go be updated using the go install command?
Not. That's simply not the way to manage the installation of Go. Being able to "go install" a certain version is a nice shortcut to get a certain version of Go up and running but it's not the intended way to manage "the" Go installation on your machine.
Related
I've freshly installed Ubuntu 18.04 and have decided to try Anaconda. However, when I then try to install Mendeley, I get the following error:
mendeleydesktop depends on python; however:
Package python is not installed.
I assume the issue here is that python is now in ~\anaconda2\bin, instead of \usr\bin. I'm not certain what I should do. As I see it, I have 3 options:
Install a system python into \usr\bin, but this seems sloppy/messy
Put a softlink in \usr\bin along the lines of ln -s python ~\anaconda2\bin\python, but I'm worried that there might be implications to that, which I don't understand
Somehow tell the mendeley.deb file where the python I'm using is, but I don't know how to do this.
Are either 1 or 2 reasonable options? If not how do I implement my 3rd option, or what else should I do?
Empirically found option 2 does not work. dpkg is still looking for the installation of the python package
You can use the method given here to remove the system python dependency in the .deb file; I tried this and mendeley seems to install as normal. Assuming your conda environment is set up correctly, it will work. I had to modify the instructions on that page slightly:
Unpack deb: $ ar x mendeleydesktop_1.19.4-stable_amd64.deb (will create i.e. three files: debian-binary control.tar.gz data.tar.gz)
Unpack control archive: $ tar xzf control.tar.gz (will create: postinst control)
Fix dependencies in control (use a text editor)
Repack control.tar.gz: $ tar c postinst control | gzip -c > control.tar.gz
Repack deb: $ ar rcs mendeleydesktop_1.19.4-stable_amd64_nopythondep.deb debian-binary control.tar.gz data.tar.gz (order important! dpkg wouldn't be able to read the metadata of a package quickly if it had to search for where the data section ended!)
I need to use the test driven development in Go using "gotests" command.
gotests -all *
This is not working. I did go get -u /github.com/cweill/gotests
and go install. But there is no binary created in $GOPATH/bin.
since there is NO main package, Use this command
$ go get github.com/cweill/gotests/...
this itself download all dependencies for the current package, and creates bin file, after downloading this package. see in $GOPATH/bin there will be a bin file named gotests
for more see HERE
The following worked for me with go v1.19.1
go install github.com/cweill/gotests/gotests#latest
Using go get to install things has been disabled since 1.18. See Deprecation of 'go get' for installing executables
go install github.com/rakyll/gotest
Source: https://github.com/rakyll/gotest
This is my first time with GO.
/* hello.go My first GOlang program */
package main
import "fmt"
func main() {
fmt.Printf("Hello World\n")
}
I am getting this error:
# command-line-arguments
/usr/local/go/pkg/tool/darwin_amd64/6g: unknown flag -trimpath
I am not able to understand what is the problem.
Apparently, this is related to the way go has been installed.
See GOlang Some Common Errors
after trying 1.3 meant “you need to unapck your .tar.gz file to /usr/local
http://golang.org/doc/install#tarball
One can not just install the golang 1.3 from the installer, you should try out the untar option for better results.
Errors found during :
brew install spiff
go install github.com/tools/godep
# github.com/kr/fs
/usr/local/go/pkg/tool/darwin_amd64/6g: unknown flag -trimpath
So follow the install section
Download the archive and extract it into /usr/local, creating a Go tree in /usr/local/go.
For example:
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
Choose the archive file appropriate for your installation. For instance, if you are installing Go version 1.3 for 64-bit x86 on Linux, the archive you want is called go1.3.linux-amd64.tar.gz.
Add /usr/local/go/bin to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile.
export PATH=$PATH:/usr/local/go/bin
To uninstall and start over: see Uninstall Go
To remove an existing Go installation from your system delete the go directory. This is usually /usr/local/go under Linux, Mac OS X, and FreeBSD or c:\Go under Windows.
You should also remove the Go bin directory from your PATH environment variable.
Under Linux and FreeBSD you should edit /etc/profile or $HOME/.profile. If you installed Go with the Mac OS X package then you should remove the /etc/paths.d/go file.
Every time I try to compile my program after (this morning) upgrading go from 1.1.1 to 1.1.2 (on Windows 7 64 bits), I get error message like:
C:\Users\VonC\prog\go\src\github.com\spf13\hugo>go build -o hugo.exe main.go
# github.com/spf13/hugo/hugolib
hugolib\page.go:23: import C:\Users\VonC\prog\go\pkg\windows_amd64/github.com/emicklei/hopwatch.a:
object is [windows amd64 go1.1.1 X:none]
expected [windows amd64 go1.1.2 X:none]
I tried a go clean -r, but the error message persists?
What is the right clean command to use?
Actual solution:
I reproduced the issue with:
calling the 1.1.2 go.exe directly (I didn't have %GOROOT%\bin in my path)
with GOROOT pointing to the previous 1.1.1 installation folder (I kept go 1.1.1 and 1.1.2 installed in separated folders).
If you are sticking with the default go setup (ie: one C:\go installation directory, and %GOROOT%\bin in your PATH), you won't see this error.
But if you do see this error:
make sure %GOROOT% is consistent with the go.exe you are calling
go install -a as explained below. The go clean mentioned below won't be necessary.
As jnml comments:
the Go build system is supposed to figure out any obsolete stuff in $GOPATH/pkg and (transitively) rebuild it on demand.
Original solution:
In the "Remove object files" section of "Command go" page, I missed the go clean -i option:
-i
The -i flag causes clean to remove the corresponding installed archive or binary (what 'go install' would create).
And those .a file (like hopwatch.a) are precisely what go install generates for libraries (in Windows).
So the full clean command, to make sure go rebuild everything, would be:
cd C:\Users\VonC\prog\go\src\github.com\spf13\hugo
go clean -r -i
go install -a
That will rebuild and install everything, including all dependent packages.
The -a is actually a build option, which forces rebuilding of packages that are already up-to-date.
As usual, go clean -r -n would show you what would be cleaned (-n: preview option).
It doesn't hurt to be sure of what will be deleted... before actually deleting anything.
A friend sent me along this great tutorial on webscraping The New York Times with R. I would really love to try it. However, the first step is to install a package called [RJSONIO][2] from source.
I know R reasonably well, but I have no idea how to install a package from source.
I'm running macOS (OS X).
If you have the file locally, then use install.packages() and set the repos=NULL:
install.packages(path_to_file, repos = NULL, type="source")
Where path_to_file would represent the full path and file name:
On Windows it will look something like this: "C:\\RJSONIO_0.2-3.tar.gz".
On UNIX it will look like this: "/home/blah/RJSONIO_0.2-3.tar.gz".
Download the source package, open Terminal.app, navigate to the directory where you currently have the file, and then execute:
R CMD INSTALL RJSONIO_0.2-3.tar.gz
Do note that this will only succeed when either: a) the package does not need compilation or b) the needed system tools for compilation are present. See: R for Mac OS X
You can install directly from the repository (note the type="source"):
install.packages("RJSONIO", repos = "http://www.omegahat.org/R", type="source")
A supplementarily handy (but trivial) tip for installing older version of packages from source.
First, if you call "install.packages", it always installs the latest package from repo. If you want to install the older version of packages, say for compatibility, you can call install.packages("url_to_source", repo=NULL, type="source"). For example:
install.packages("http://cran.r-project.org/src/contrib/Archive/RNetLogo/RNetLogo_0.9-6.tar.gz", repo=NULL, type="source")
Without manually downloading packages to the local disk and switching to the command line or installing from local disk, I found it is very convenient and simplify the call (one-step).
Plus: you can use this trick with devtools library's dev_mode, in order to manage different versions of packages:
Reference: doc devtools
From CRAN, you can install directly from a GitHub repository address. So if you want the package at https://github.com/twitter/AnomalyDetection, using
library(devtools)
install_github("twitter/AnomalyDetection")
does the trick.
In addition, you can build the binary package using the --binary option.
R CMD build --binary RJSONIO_0.2-3.tar.gz
If you have source code you wrote yourself, downloaded (cloned) from GitHub, or otherwise copied or moved to your computer from some other source, a nice simple way to install the package/library is:
In R
It's as simple as:
# install.packages("devtools")
devtools::install('path/to/package')
From terminal
From here, you can clone a GitHub repo and install it with:
git clone https://github.com/user/repo.git
R -e "install.packages('devtools');devtools::install('path/to/package')"
Or if you already have devtools installed, you can skip that first bit and just clone the repo and run:
R -e "devtools::install('path/to/package')"
Note that if you're on ubuntu, install these system libraries before installing devtools (or devtools won't install properly).
apt-get update
apt-get install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev libfontconfig1-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev -y