macos – How to allow firewall port open from terminal

Is there any way to set and allow a port to be open, for incoming connections from the terminal.

I am asking because I am developing on a server(mac-mini) where I am connecting into via ssh. I then need to restart and re-run many times doing developing. I am programming in golang and therefore I am running “go run main.go”.

Problem is, that I dont have access to the graphical ui – “Firewall Options…”.

I really like to have the firewall on for security reason, and I know all apps need to be signed, but maybe there is a way.

Thanks