This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/csv" | |
"fmt" | |
"log" | |
"os" | |
) | |
type userInfo struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"embed" | |
"log" | |
"net/http" | |
) | |
//go:embed static/* | |
var staticContent embed.FS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
var users = map[int]string{ | |
1: "Rob", | |
2: "Ken", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
) | |
var users = map[int]string{ | |
1: "Rob", | |
2: "Ken", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestF(t *testing.T) { | |
r := httptest.NewRequest("GET", "/", nil) | |
w := httptest.NewRecorder() | |
handler := http.HandlerFunc(F) | |
handler.ServeHTTP(w, r) | |
resp := w.Result() | |
if resp.StatusCode != http.StatusOK { | |
t.Errorf("wrong status code: got %v want %v", resp.StatusCode, http.StatusOK) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ( | |
db *sql.DB | |
logger *logging.Logger | |
once sync.Once | |
) | |
// This pattern is used to make the init function easily replaceable in tests | |
var initFunc = defaultInitFunc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package errors | |
import "github.com/sirupsen/logrus" | |
type Operation string | |
type ErrorType string | |
const ( | |
NotFoundError ErrorType = "NOT_FOUND" |