Skip to main content

3 posts tagged with "go"

View All Tags

· 5 min read
Ang Xuan Ze

Introduction

Executing a SQL query using gorm is pretty trivial. Normally this is what I'd do:

  1. Write a proto struct that matches the DB table schema
  2. Run query using gorm and Scan into the struct
var auditDb *pb.DataInjectionAuditLogDb
if err := orm.DataHelperDbInstance(g.c).Raw(q).Scan(&auditDb).Error; err != nil {
hlog.CtxErrorf(g.c, err.Error())
return nil, err
}
  1. Done

However, what if we do not know the schema, or it is virtually impossible to create a struct for all of them?

Huh?!

· 2 min read
Ang Xuan Ze

Introduction

If you want to host some ever-running script, what option do you have?

  1. Run on your laptop, and never sleep / off it (??)
  2. Get a Raspberry Pi (ugh.. overkill)
  3. Pay a few dollars to host it somewhere (few dollars to host something so small.. worth?)
  4. Ask your friend to run on his/her laptop and never off it.

Option 4 seems to be the best option if you manage to convince.

Fortunately I have the opportunity of abusing my personal VM at work. I mean, not abusing, it's somewhat related to work too. I'm sure.

· One min read
Ang Xuan Ze

Introduction

What the hell am I talking about? You might say. Well yea it sounded crazy but how long is a second exactly?!

What Happened

As I was writing some unit tests for my shiny Redis Set implementation, somethign weird caught my attention.

TestSendPotentialUsers | Successful | Written 80687641:-18230398344540846 to potential_user set

Excuse me?