Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Draven draveness

🎯
Focusing
Block or report user

Report or block draveness

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@draveness
draveness / benchmark_timers.go
Created Jul 11, 2019
Benchmark Golang Timers
View benchmark_timers.go
package main
import (
"fmt"
"sort"
"sync"
"testing"
"time"
)
View benchmark_mutex_and_channel_test.go
package main
import (
"errors"
"sync"
"testing"
)
func BenchmarkChannel(b *testing.B) {
ch := make(chan error, 1)
View timer_profile.go
package main
import (
"fmt"
"math/rand"
"sort"
"sync"
"time"
"github.com/RussellLuo/timingwheel"
View selectgo_loop.go
func selectgo(cas0 *scase, order0 *uint16, ncases int) (int, bool) {
// ...
loop:
// ...
for i := 0; i < ncases; i++ {
casi = int(pollorder[i])
cas = &scases[casi]
c = cas.c
switch cas.kind {
@draveness
draveness / main.go
Last active Mar 8, 2019
SQL Mock in Golang
View main.go
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func recordStats(db *sql.DB, userID, productID int64) (err error) {
tx, err := db.Begin()
@draveness
draveness / service.go
Last active Mar 11, 2019
Monkey Patch Mock in Golang
View service.go
package service
import (
pwi "pkg-without-interface"
)
type service struct {}
func (s *service) ListPosts() []Post {
posts := pwi.ListPosts() // ListPosts is a pkg function.
View 1-blogs-serivces-dependency-graph
+-------------------------+
| |
| |
+---------------------+ +----->| jekyll |
| | | | |
| | | +-------------------------+
| Service +------+
| |
| +------+ +-------------------------+
+---------------------+ | | |
View errors.go
errors.New("invalid parameter a")
errors.New("invalid parameter b")
errors.New("Record Not Found")
View pipelines.go
package main
import (
"context"
"errors"
"fmt"
"math/rand"
"time"
)
View simplego-lex.yy.c
#line 3 "lex.yy.c"
#define YY_INT_ALIGNED short int
/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
You can’t perform that action at this time.