Error on generating artifact Exec format error on Raspberry Pi 4

I got a Raspberry Pi 4 with 4Gb of RAM,

I have correctly followed this tutorial but at the end, when I try to create the artifact with

./docker-artifact-gen \
    -n "hello-world-container-update" \
    -t "${DEVICE_TYPE}" \
    -o "hello-world-container-update.mender" \
    "hello-world"

I have the error
./docker-artifact-gen: line 137: /home/pi/bin/mender-artifact: cannot execute binary file: Exec format error

EDIT I tried to change #!/bin/bash to #!/bin/sh but now it says Artifact name not specified. Aborting.

EDIT 2: I have tried to manually modify the fields inside the script with

device_types="raspberrypi4"
artifact_name="serial"
output_path="docker-artifact.mender"
meta_data_file="meta-data.json"
IMAGES="python:3.8-slim-buster"

but again, got ./docker-artifact-gen: 137: ./docker-artifact-gen: mender-artifact: Exec format error

There is unfortunately a chicken and egg problem when making docker updates for Raspberry Pi (or any ARM platform): Mender doesn’t offer ARM downloads of mender-artifact, and you can’t make Docker updates for Raspberry Pi using an x86 build host, since it would be the wrong architecture.

It should be relatively straightforward to compile it though. Just install the golang and liblzma-dev packages, git clone the mender -artifact repository, and run make and sudo make install.

Running make just after cloning repo on an ARM device but even on an AMD device complains with:

go build -ldflags "-X github.com/mendersoftware/mender-artifact/cli.Version=a292a1a"  
main.go:21:2: cannot find package "github.com/mendersoftware/mender-artifact/cli" in any of:
	/usr/lib/go-1.10/src/github.com/mendersoftware/mender-artifact/cli (from $GOROOT)
	/home/$USER/go/src/github.com/mendersoftware/mender-artifact/cli (from $GOPATH)
Makefile:41: recipe for target 'build' failed
make: *** [build] Error 1

EDIT: Solved using latest version of GO (1.18)

mender-artifact for ARM successfully built