How To Make A Simple Go Program To Track The Price Of Steem Via An API

Earlier today I wrote a quick tutorial on how to use golang to track STEEM or any cryptocurrency for that matter. You can find the post on my Steemit account @tenghamn on steemit here https://steemit.com/cryptocurrency/@tenghamn/how-to-make-a-simple-go-program-to-track-the-price-of-steem-via-an-api

The current script is pretty simple and I plan to expand on it to make a tool that will allow you to track any cryptocurrencies along with a gained or lost amount or percentage based on at what price and how much you purchased these coins for.

You can find the entire script on github here: https://github.com/markustenghamn/golang-steem-cryptotracker

Switching From Nginx To Caddy

I am a long time user of Apache, it was the first web server software I learned to use and therefore it felt like a no brainer to always use it. However over the past year I have started using Nginx more and more. It felt foreign at first but once you get a hang of how to configure new hosts and do the initial setup it’s really just as easy to use as Apache and in my current opinion, much better when it comes to memory usage and the amount of requests it can handle. If you want to read more about the differences you can read this post from tutsplus that describes the pros and cons of using either one for a wordpress website (generally the things discussed here applies to most other applications).

There you have some background information, so what’s Caddy and why should I switch to it? Caddy is written in go and is much easier to use compared to Nginx or Apache but I would not claim that it’s better than either of these. There is a pretty good article describing the differences of Nginx and Caddy here. So why use it? Well with Nginx I have the main configuration file and an additional host file. Here is a full example configuration from the Nginx docs.

So let’s take a look at Caddy, here is what my config file might look like if I was setting up a Laravel website.

example.com {
    root ./public
    fastcgi / 127.0.0.1:9000 php
    rewrite {
        to {path} {path}/ /index.php?{query}
    }
}

That’s it. That’s all the configuration I need to write to get my Laravel site up and running. If I want to add another host on my Caddy server I can simply add another host under this one with the same structure.

The best part is you can automatically download, verify and configure ssl certificates from Let’s Encrypt for any domain as long as the domain already points to your server.

Caddy is written in go and supports plugins. To install plugins simply download the Caddy source and import your plugins, you can find a list of plugins on the Caddy forums.

Learning Go

So I have spent the past few weeks trying to get better at Go. I wanted to share a really good resource that I found useful and it’s called Go By Example. I love this site because it provides easy to understand examples for pretty much any of the basic things in Go. As a PHP developer I know how I would like to solve a problem, perhaps I need a for loop and maybe I don’t feel 100% sure how to write this. In that case I can turn to go by example which has a great example of a for loop in go.

So lately I have been working on my side project tournify.io which is a site where you can create tournaments for free. The current site is written in Laravel and contains plenty of bugs. My current goal is to rewrite all the logic with a go backend and use ReactJS for the front end. I have my good friend Alx101 helping me with the frontent. Both Go and ReactJS is pretty new to us so we will see how it goes.

Hello World!

As I start writing on GoPHP.io I find myself a complete beginner to golang. I began using PHP for an ecommerce site when I was 13 and have used PHP ever since. I feel that now is a good time to learn and perhaps master a new language and I picked Go!

So what’s the plan with this website, where will it be heading? I hope to create a useful site with plenty of guides and useful tips based on what I am currently learning and finding as I go. Why would I make such a site? I like teaching and helping others and a site such as this one gives me an outlet and a hobby where I can do those things.

This is just a quick intro post. Hopefully I will complete and finish my first guide soon. If you would like to follow me on a more personal level, feel free to check out my blog at tenghamn.com.