Skip to content

Instantly share code, notes, and snippets.

View Tom5521's full-sized avatar
💭
Writing an interpreter in Go

Tom Tom5521

💭
Writing an interpreter in Go
View GitHub Profile
#!/bin/bash
name="$1"
url="$2"
if [[ $name == "" ]]; then
echo No name provided.
exit 1
fi
@Tom5521
Tom5521 / git_submodules.md
Created July 2, 2024 00:30 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
#!/bin/bash
gsettings set org.gnome.desktop.interface color-scheme prefer-dark
@Tom5521
Tom5521 / main.sh
Created February 9, 2024 07:07 — forked from pojntfx/main.sh
Cross-compile and package GTK4/libadwaita apps for Windows from Linux with MSYS2 and WINE
#!/bin/bash
# Install native dependencies
sudo dnf update -y
sudo dnf install -y curl wine
# Install MSYS2
curl -L -o /tmp/msys2.exe 'https://github.com/msys2/msys2-installer/releases/download/2021-11-30/msys2-base-x86_64-20211130.sfx.exe'
wine64 /tmp/msys2.exe x -y -oC:/
@Tom5521
Tom5521 / Elevate when needed in Go.md
Created September 21, 2023 19:58 — forked from jerblack/Elevate when needed in Go.md
Relaunch Windows Golang program with UAC elevation when admin rights needed.

I'm buiding a command line tool in Go that has an option to install itself as a service on Windows, which it needs admin rights for. I wanted to be able to have it reliably detect if it was running as admin already and if not, relaunch itself as admin. When the user runs the tool with the specific switch to trigger this functionality (-install or -uninstall in my case) they are prompted by UAC (User Account Control) to run the program as admin, which allows the tool to relaunch itself with the necessary rights.

To detect if I was admin, I tried the method described here first:
https://coolaj86.com/articles/golang-and-windows-and-admins-oh-my/
This wasn't accurately detecting that I was elevated, and was reporting that I was not elevated even when running the tool in CMD prompt started with "Run as Administrator" so I needed a more reliable method.

I didn't want to try writing to an Admin protected area of the filesystem or registry because Windows has the ability to transparently virtualize those writes

@Tom5521
Tom5521 / 0-go-os-arch.md
Created July 22, 2023 13:44 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
$ go tool dist list
android/386
android/amd64
android/arm
android/arm64
darwin/386
darwin/amd64
darwin/arm
darwin/arm64
dragonfly/amd64