This file contains 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" | |
"net/http" | |
"sync" | |
"time" | |
) | |
const ( |
This file contains 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
-- -*- coding: utf-8 -*- | |
-- | |
-- Simple JSON encoding and decoding in pure Lua. | |
-- | |
-- Copyright 2010-2017 Jeffrey Friedl | |
-- http://regex.info/blog/ | |
-- Latest version: http://regex.info/blog/lua/json | |
-- | |
-- This code is released under a Creative Commons CC-BY "Attribution" License: | |
-- http://creativecommons.org/licenses/by/3.0/deed.en_US |
This file contains 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 ( | |
"database/sql" | |
"os" | |
"fmt" | |
"log" | |
_ "github.com/lib/pq" |
This file contains 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 | |
/* | |
Playground: https://go.dev/play/p/81iyOZMOeMP | |
Output: | |
batch: [1 2 3 4 5 6 7 8 9 10] | |
batch: [11 12 13] | |
*/ |
This file contains 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
// Code generated by MockGen. DO NOT EDIT. | |
// Source: mocking.go | |
// Package sample is a generated GoMock package. | |
package sample | |
import ( | |
reflect "reflect" | |
gomock "github.com/golang/mock/gomock" |
This file contains 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 unittest | |
import ( | |
"context" | |
"errors" | |
"log" | |
"time" | |
"github.com/tokopedia/kunyit/src/conf" | |
"github.com/tokopedia/sqlt" |
This file contains 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
#!/bin/bash | |
set -e | |
echo 'mode: count' > profile.cov | |
for dir in $(find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path '*/vendor*' -type d); | |
do | |
if ls $dir/*.go &> /dev/null; then | |
go test -short -covermode=count -coverprofile=$dir/profile.tmp $dir | |
if [ -f $dir/profile.tmp ] |
This file contains 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
nakama@slack-gary:~/go$ go test -bench=. | |
goos: linux | |
goarch: amd64 | |
BenchmarkIsFraud1-4 200000 5510 ns/op | |
BenchmarkIsFraud10-4 200000 6340 ns/op | |
BenchmarkIsFraud100-4 100000 15631 ns/op | |
BenchmarkIsFraud1000-4 20000 69969 ns/op | |
BenchmarkIsFraudByMap1-4 1000000 1013 ns/op | |
BenchmarkIsFraudByMap10-4 300000 4962 ns/op | |
BenchmarkIsFraudByMap100-4 30000 44113 ns/op |
This file contains 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 fraud | |
import ( | |
"flag" | |
"os" | |
"strings" | |
"testing" | |
) | |
This file contains 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 redis | |
import ( | |
redigo "github.com/garyburd/redigo/redis" | |
) | |
// HMGET is a common usage of Redis command HMGET | |
func (r *redis) HMGET(key string, fields ...string) ([]string, error) { | |
conn := r.Pool.Get() | |
defer conn.Close() |