Update Go Installation Script and Adjust Directory Structure
- Changed GOROOT path from "$HOME/.local/go" to "$HOME/go" for improved clarity and consistency. - Removed unnecessary creation of the "$HOME/.local" directory, simplifying the installation process. - Updated the download and extraction process for Go to use the home directory, enhancing usability. - Cleaned up the script by removing redundant commands and improving overall readability.
This commit is contained in:
@@ -7,7 +7,7 @@ set -e
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
GO_VERSION="1.23.1"
|
GO_VERSION="1.23.1"
|
||||||
GOROOT="$HOME/.local/go"
|
GOROOT="$HOME/go"
|
||||||
GOPATH="$HOME"
|
GOPATH="$HOME"
|
||||||
GOBIN="$HOME/.local/bin"
|
GOBIN="$HOME/.local/bin"
|
||||||
GOENV_FILE="$HOME/.goenv"
|
GOENV_FILE="$HOME/.goenv"
|
||||||
@@ -84,13 +84,11 @@ install_go() {
|
|||||||
local download_url="https://golang.org/dl/${go_archive}"
|
local download_url="https://golang.org/dl/${go_archive}"
|
||||||
|
|
||||||
# Create directories
|
# Create directories
|
||||||
mkdir -p "$HOME/.local"
|
|
||||||
mkdir -p "$GOPATH"
|
|
||||||
mkdir -p "$GOBIN"
|
mkdir -p "$GOBIN"
|
||||||
|
|
||||||
# Download and extract Go
|
# Change to home directory and download Go
|
||||||
log_info "Downloading Go from $download_url..."
|
log_info "Downloading Go from $download_url..."
|
||||||
cd /tmp
|
cd ~
|
||||||
wget -q "$download_url" || {
|
wget -q "$download_url" || {
|
||||||
log_error "Failed to download Go"
|
log_error "Failed to download Go"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -104,8 +102,7 @@ install_go() {
|
|||||||
|
|
||||||
# Extract Go
|
# Extract Go
|
||||||
log_info "Extracting Go to $GOROOT..."
|
log_info "Extracting Go to $GOROOT..."
|
||||||
tar -xf "$go_archive" -C "$HOME/.local/"
|
tar -xf "$go_archive"
|
||||||
mv "$HOME/.local/go" "$GOROOT"
|
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
rm -f "$go_archive"
|
rm -f "$go_archive"
|
||||||
|
|||||||
Reference in New Issue
Block a user