Skip to content

Instantly share code, notes, and snippets.

Teiva Harsanyi teivah

Block or report user

Report or block teivah

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 sequence_test.go
var seqMutex sync.Mutex
func seq() func() {
seqMutex.Lock()
return func() {
seqMutex.Unlock()
}
}
func TestFoo(t *testing.T) {
View time.go
var now = time.Now
func duration(d time.Duration) time.Time {
return now().Add(d)
}
View time.go
func duration(d time.Duration) time.Time {
return time.Now().Add(d)
}
View time_test.go
func Test_duration(t *testing.T) {
oldNow := now
defer func() {now = oldNow}()
now = func() time.Time {
current, _ := time.Parse(time.RFC3339, "2000-01-08T20:00:00.000Z")
return current
}
expected, _ := time.Parse(time.RFC3339, "2000-01-08T21:00:00.000Z")
View time.go
package main
import (
"fmt"
"time"
)
var now = time.Now
func main() {
View time.go
package main
import (
"fmt"
"time"
)
func main() {
t := duration(time.Now(), time.Second)
fmt.Printf("%v\n", t)
View time.go
package main
import (
"fmt"
"time"
)
func main() {
t := duration(time.Second)
fmt.Printf("%v\n", t)
View shebang.go
#!/usr/bin/env gorun
package main
import "fmt"
func main() {
fmt.Print("Hello, World!\n")
}
View shebang.go
//usr/local/go/bin/go run "$0" "$@"; exit "$?"
package main
import "fmt"
func main() {
fmt.Print("Hello, World!\n")
}
View shebang.go
#!/usr/bin/env gorun
package main
import "fmt"
func main() {
fmt.Print("Hello, World!\n")
}
You can’t perform that action at this time.