If it won't be simple, it simply won't be. [Hire me, source code] by Miki Tebeka, CEO, 353Solutions

Tuesday, February 04, 2020

Adding a timer to Go's "present" tool

Go has a nice present tool which let's you present code and run it. I wanted to use it in my lightning talk at GopherCon Israel. The talk is a quiz and I wanted a timer to show on each quiz slide.

present syntax supports .html directive which lets you add any HTML code to the slide. From there it easy to add a timer. I wrote timer.html below and added .html timer.html to the first slide.

Here's how it looks (bottom left):

Here's the code:

Sunday, January 05, 2020

Nested structs for HTTP Calls

Some API's return complex structures. Here's for an example from Stocktwits API.
Instead of creating a specific type for every element in the structre, we use use a anonymous structure and define only the fields we're intrested in. In our example we'd like to see the symbols most mentioned for a given symbol (in our case AAPL). And the output:
$ go run stocktwits.go
SPY    10
TSLA    7
AMZN    5
BTC.X   5
TVIX    2

Blog Archive