Upgrade to Pro — share decks privately, control downloads, hide ads and more …

最速のクエリビルダを妄想してみた

 最速のクエリビルダを妄想してみた

mackee

June 13, 2015
Tweet

More Decks by mackee

Other Decks in Programming

Transcript

  1. GoͷΫΤϦϏϧμ • lann/squirrel import sq “github.com/lann/squirrel” query, args, err :=

    sq.Select(“id”, “name”).From(“user”).Where(sq.Eq{“id”: id}).ToSql() row := db.QueryRow(query, args…)
  2. go generate • Go͸1.4͔Βgo generateͱ͍͏࢓૊Έ͕௥Ճ ͞Εͨ • //go:generate hogehoge •

    ͜ΕΛهड़ͨ͠ιʔε͕ଘࡏ͢Δͱ͜ΖͰgo generateͬͯίϚϯυΛଧͭͱhogehogeͬͯ ͍͏ͷ͕γΣϧͰ࣮ߦ͞ΕΔ
  3. ͔͜͜Βauto generated type Name struct { Name string Expr sqlla.Expr

    } func (c Name) ToSql() { return “name “ + c.Expr.ToSql() + “?” }