SQLite3 with golang without CGO

18.04.2025 / by Jens / in Linux Windows golang sqlite

Everytime I start a new golang project that needs a database, I make the same mistake. I add the most recommended sqlite mod to my project, build it and get told, that I miss gcc on my machine. As I dont want to install mingw or something like that, I have then to search again for that pure-golang implementation.

Here it is, so I don't have to search for that again:

https://github.com/glebarez/go-sqlite

go get github.com/glebarez/go-sqlite

Manage a blog with blogger

28.03.2025 / by Jens / in Software

I wanted to have a website again, to collect information I found in the internet that I might need again some time, and maybe to present some pictures, when I take some on vacations.

Because I didn't want to use wordpress or write my own web cms, and I started to look into "new" languages, I built a small cli application in GO, that reads .md files and converts them into .html files for a blog.

Currently it is extremly limited and there are still some features I'd like to add, like adding static content pages, generate a json file to support javascript-search etc. At this moment I am not able to use more than one image per post, so the idea of showing photos from vacations isn't possible yet.

As soons as I am done with a basic featureset, I might make the github for this little project public. Perhaps someone is interested in using it.

Edit 2025-03-15

I can now generate content pages (see impressum) with blogger.

Edit 2025-03-28

I wrote my own template that I seem to like. I also added the generation a javascript file that contains a json object with keywords to implement a javascript search.

Edit 2025-04-18

Finally the website updates itself after I pushed the artice into my "cms-repository"

Crosscompile Go on Win for Linux

27.03.2025 / by Jens / in Linux Windows golang

To cross compile a golang application on windows to run on linux you need to set the environment first:

set GOARCH=amd64
set GOOS=linux

If you are using a powershell, this needs to be set differently

$Env:GOARCH="amd64";$Env:GOOS="linux"

If you don't have the environment install already, golang documentation recommends the following 2 steps. The first one didn't work on my machine, but seems it wasn't needed.

go tool dist install -v pkg/runtime
go install -v -a std

After that you can simply build the project. It should generate an executable without the .exe

go build

Hetzner Cloud Setup

26.03.2025 / by Jens / in Linux Ubuntu Hetzner Cloud

Add user to sudoer list

sudo usermod -aG sudo USERNAME

Generate locale

sudo locale-gen de_DE
sudo locale-gen de_DE.UTF-8
sudo update-locale LANG=de_DE.UTF-8

You need to relogin

Install golang

sudo snap install go --classic

Allow executable to bind to port

24.03.2025 / by Jens / in Linux Terminal

I want to test some webservices written in go. I don't want to have that application run with root permissions, so I want to start it as user. As all ports below 1024 are seen as privileged, I have to "sign" the executable for it.

sudo setcap 'cap_net_bind_service=+ep' /path/to/executable

Copy & Paste in TMUX

12.03.2025 / by Jens / in Linux Terminal TMUX

To use copy and paste you need to do the following:

PREFIX [

Move the cursor to the first character you want to copy

PREFIX SPACE

Move the mouse to the last character you want to copy

PREFIX #

Where # is the screen you want to switch to

PREFIX ]

Mount remote directory

11.03.2025 / by Jens / in Linux Terminal

To connect to a remove server, you can use the tool sshfs. It mounts a remote directory via ssh to a local folder.

sshfs -p PORT USER@REMOVESERVER:REMOTEPATH LOCALPATH

Sync dotfiles with github

10.03.2025 / by Jens / in Linux

To backup and share my configurations for neovim, tmux, bash etc. I wanted to sync my local dotfiles to github. I found the following article, that I used to it.

https://www.anand-iyer.com/blog/2018/a-simpler-way-to-manage-your-dotfiles/

So make it short:

mkdir $HOME/.dotfiles
git init --bare $HOME/.dotfiles

Add alias to .*rc (.bashrc, .zshrc)

alias dotfiles='/usr/local/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
dotfiles config --local status.showUntrackedFiles no
dotfiles remote add origin git@github.com:anandpiyer/.dotfiles.git
cd $HOME
dotfiles add .tmux.conf
dotfiles commit -m "Add .tmux.conf"
dotfiles push

Setting up a new machine

git clone --separate-git-dir=$HOME/.dotfiles https://github.com/anandpiyer/.dotfiles.git ~
git clone --separate-git-dir=$HOME/.dotfiles https://github.com/anandpiyer/.dotfiles.git tmpdotfiles
rsync --recursive --verbose --exclude '.git' tmpdotfiles/ $HOME/
rm -r tmpdotfiles