As we known, standard httprouter func has 3 parameters like below: func ViewIndex(w http.ResponseWriter, r *http.Request, ps httprouter.Params){} Sometimes, we need pass additional arguments to httprouter handle func, like: func ViewIndex(w http.ResponseWriter, r *http.Request, ps httprouter.Params, settings map[string]string){} There are two ways to achive this target: Use a wrapper func getIndexWithSettings2(s Settings) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { // // Settings is in the scope and ps httprouter.

Read More…

(1) Background To fix following issue: Add “contains” operator in where function to support list pages in nested subdir I implemented a new contains operator in Hugo where function in following PR: tpl: Add “contains” operator in where tpl function (2) How Hugo where function works Basically Hugo where function use the checkCondition() function to check if the given field value matches the match value or not.

Read More…

makefile in golang

2017-11-17

Why go install already checks if the binary is up-to-date before installation. go test is all you need to kick-off tests that run at face melting speed. It’s natural to ask, “Why do I need a Makefile?” It because make is useful because it’s executable documentation. It describes how to build your project, what kind of tests can be run and the external tools your project depends on and so on.

Read More…