-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Golang #2162
Draft
slashtechno
wants to merge
15
commits into
Botspot:master
Choose a base branch
from
slashtechno:add-golang
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add Golang #2162
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5d86420
Added Go
slashtechno e164367
Added Go to categories
slashtechno 7186b18
Correct file permissions for install and uninstall files
github-actions[bot] 3aa5a78
Changed Go version to 1.19.2
slashtechno ff3cdc0
Merge branch 'add-golang' of github.com:slashtechno/pi-apps into add-…
slashtechno c22cbfb
Get rid of unnecessary script functions
slashtechno d4ec0bf
Use existing `arch` var for install
slashtechno b8d7f97
Cleaned up code
slashtechno cf6e56e
Fixed more miscellaneous issues in install script
slashtechno 8e5055a
Get rid of MacOS-specific code in uninstall
slashtechno a52718a
Fixed `$shell_profile` in uninstall script
slashtechno 4aa8921
Added error checking, fixed variables
slashtechno 062ad95
Rename `$VERSION` to `$version`
slashtechno 67154f0
Removed unintentional whitespace in credits
slashtechno ec1bdf7
Merge branch 'Botspot:master' into add-golang
slashtechno File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(github.com/.../...) | ||
canha/golang-tools-install-scrip t - the install script | ||
golang/go - the language itself | ||
slashtechno - addition to Pi-Apps |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
|
||
[ -z "$GOROOT" ] && GOROOT="$HOME/.go" | ||
[ -z "$GOPATH" ] && GOPATH="$HOME/go" | ||
|
||
case "$arch" in | ||
"64") | ||
PLATFORM="linux-arm64" | ||
;; | ||
"32") | ||
PLATFORM="linux-armv6l" | ||
;; | ||
*) | ||
error "arch variable is not set, can not continue" | ||
;; | ||
esac | ||
|
||
if [ -z "$PLATFORM" ]; then | ||
echo "Your operating system is not supported by the script." | ||
exit 1 | ||
fi | ||
|
||
if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then | ||
shell_profile="$HOME/.zshrc" | ||
elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then | ||
shell_profile="$HOME/.bashrc" | ||
elif [ -n "$($SHELL -c 'echo $FISH_VERSION')" ]; then | ||
shell="fish" | ||
if [ -d "$XDG_CONFIG_HOME" ]; then | ||
shell_profile="$XDG_CONFIG_HOME/fish/config.fish" | ||
else | ||
shell_profile="$HOME/.config/fish/config.fish" | ||
fi | ||
fi | ||
|
||
if [ ! -z "$1" ]; then | ||
echo "Unrecognized option: $1" | ||
exit 1 | ||
fi | ||
|
||
if [ -d "$GOROOT" ]; then | ||
echo "The Go install directory ($GOROOT) already exists. Exiting." | ||
exit 1 | ||
fi | ||
|
||
PACKAGE_NAME="go$version.$PLATFORM.tar.gz" | ||
TEMP_DIRECTORY=$(mktemp -d) | ||
|
||
echo "Downloading $PACKAGE_NAME ..." | ||
if hash wget 2>/dev/null; then | ||
slashtechno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
wget https://storage.googleapis.com/golang/$PACKAGE_NAME -O "$TEMP_DIRECTORY/go.tar.gz" | ||
else | ||
curl -o "$TEMP_DIRECTORY/go.tar.gz" https://storage.googleapis.com/golang/$PACKAGE_NAME | ||
fi | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Download failed! Exiting." | ||
exit 1 | ||
fi | ||
|
||
echo "Extracting File..." | ||
mkdir -p "$GOROOT" | ||
|
||
tar -C "$GOROOT" --strip-components=1 -xzf "$TEMP_DIRECTORY/go.tar.gz" | ||
slashtechno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
echo "Configuring shell profile in: $shell_profile" | ||
touch "$shell_profile" | ||
if [ "$shell" == "fish" ]; then | ||
{ | ||
echo '# GoLang' | ||
echo "set GOROOT '${GOROOT}'" | ||
echo "set GOPATH '$GOPATH'" | ||
echo 'set PATH $GOPATH/bin $GOROOT/bin $PATH' | ||
} >> "$shell_profile" | ||
else | ||
{ | ||
echo '# GoLang' | ||
echo "export GOROOT=${GOROOT}" | ||
echo 'export PATH=$GOROOT/bin:$PATH' | ||
echo "export GOPATH=$GOPATH" | ||
echo 'export PATH=$GOPATH/bin:$PATH' | ||
} >> "$shell_profile" | ||
fi | ||
|
||
mkdir -p "${GOPATH}/"{src,pkg,bin} | ||
echo -e "\nGo $version was installed into $GOROOT.\nMake sure to relogin into your shell or run:" | ||
echo -e "\n\tsource $shell_profile\n\nto update your environment variables." | ||
echo "Tip: Opening a new terminal window usually just works. :)" | ||
rm -f "$TEMP_DIRECTORY/go.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then | ||
shell_profile="$HOME/.zshrc" | ||
elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then | ||
shell_profile="$HOME/.bashrc" | ||
elif [ -n "$($SHELL -c 'echo $FISH_VERSION')" ]; then | ||
shell="fish" | ||
if [ -d "$XDG_CONFIG_HOME" ]; then | ||
shell_profile="$XDG_CONFIG_HOME/fish/config.fish" | ||
else | ||
shell_profile="$HOME/.config/fish/config.fish" | ||
fi | ||
fi | ||
rm -rf "$GOROOT" | ||
slashtechno marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if [ "$shell" == "fish" ]; then | ||
sed -i '/# GoLang/d' "$shell_profile" | ||
sed -i '/set GOROOT/d' "$shell_profile" | ||
sed -i '/set GOPATH/d' "$shell_profile" | ||
sed -i '/set PATH $GOPATH\/bin $GOROOT\/bin $PATH/d' "$shell_profile" | ||
else | ||
sed -i '/# GoLang/d' "$shell_profile" | ||
sed -i '/export GOROOT/d' "$shell_profile" | ||
sed -i '/$GOROOT\/bin/d' "$shell_profile" | ||
sed -i '/export GOPATH/d' "$shell_profile" | ||
sed -i '/$GOPATH\/bin/d' "$shell_profile" | ||
fi | ||
echo "Go removed." | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://go.dev/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To signify that the following lines are Github links in the form of
username/repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just add them as links directly then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, it looks cleaner this way.