This project show how to make a GO API with HTTPS access. The certificate is made by Let's Encrypt so web browser doesn't send Security warning.
git clone https://github.com/certbot/certbot
cd certbot
./certbot-auto --helpOR follow : https://certbot.eff.org/lets-encrypt/ubuntubionic-other
./certbot-auto certonly --preferred-challenges http-01 -d www.domain.comOR (if you followed the installation using the certbot website) :
certbot certonly --preferred-challenges http-01 -d www.domain.com Saving debug log to /var/log/letsencrypt/letsencrypt.logUsing the "net/http" library to server on the desired port.
PORT := "8081"
http.ListenAndServeTLS(":"+PORT, "/etc/letsencrypt/live/www.domain.com/fullchain.pem", "/etc/letsencrypt/live/www.domain.com/privkey.pem", nil)and (to use gin-gonic) :
PORT := "8081"
router := gin.Default()
http.ListenAndServeTLS(":"+PORT, "/etc/letsencrypt/live/www.domain.com/fullchain.pem", "/etc/letsencrypt/live/www.domain.com/privkey.pem", router)