Skip to content

Instantly share code, notes, and snippets.

🎯
Building Abstractions

Draven draveness

🎯
Building Abstractions
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
View golang-syscall.csv
Syscall Type
SYS_TIME RawSyscall
SYS_GETTIMEOFDAY RawSyscall
SYS_SETRLIMIT RawSyscall
SYS_GETRLIMIT RawSyscall
SYS_EPOLL_WAIT Syscall
SYS_MMAP2 Syscall
SYS__NEWSELECT Syscall
SYS_SETGROUPS32 RawSyscall
SYS_GETGROUPS32 RawSyscall
@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"
)
You can’t perform that action at this time.