Skip to content

Instantly share code, notes, and snippets.

View 178inaba's full-sized avatar
🤔
hello, world

Masahiro Furudate 178inaba

🤔
hello, world
View GitHub Profile
@178inaba
178inaba / main.go
Created November 20, 2022 16:09
DB to JSON by Go.
package main
import (
"encoding/json"
"log"
"os"
"github.com/brianvoe/gofakeit/v6"
)
@178inaba
178inaba / main.go
Created December 4, 2021 15:46
Original http status text by `http.Hijacker`.
package main
import (
"fmt"
"log"
"net/http"
)
func indexHandler(w http.ResponseWriter, req *http.Request) {
hj, ok := w.(http.Hijacker)
@178inaba
178inaba / main.go
Created January 25, 2021 03:51
Check `errors.Is()`.
package main
import (
"errors"
"fmt"
"io"
)
func main() {
err := fmt.Errorf("fail: %w", fmt.Errorf("fail: %w", io.EOF))
@178inaba
178inaba / main.go
Last active January 17, 2021 05:44
Separate slice percentage.
package main
import (
"fmt"
"math"
)
func main() {
a := 51
b := 35
@178inaba
178inaba / main.go
Last active January 4, 2021 17:28
Append map slice.
package main
import (
"fmt"
)
type foo struct {
i int
}
@178inaba
178inaba / main.go
Created December 31, 2020 17:57
Append empty slice in struct.
package main
import "fmt"
type classRoom struct {
ids []int
}
func main() {
var cr classRoom
package main
import "fmt"
func main() {
a := make([]int, 5001)
for i := 0; i < 5001; i++ {
a[i] = i
}
@178inaba
178inaba / circleci.md
Last active July 1, 2020 09:19
Kick CircleCI pipeline by specifying branch.
curl -X POST -H 'Circle-Token:foo' -H 'Content-Type:application/json' -d '{"branch":"bar"}' https://circleci.com/api/v2/project/github/baz/app/pipeline
@178inaba
178inaba / main.go
Created June 11, 2020 16:48
UTC to JST(Asia/Tokyo) in Go
package main
import (
"fmt"
"time"
)
func main() {
time.Local = time.UTC
jstLoc := time.FixedZone("Asia/Tokyo", int(9*time.Hour/time.Second))
@178inaba
178inaba / main.go
Created May 15, 2020 22:43
Testing cache mechanism using gob encoding and Redis. Version 2.
package main
import (
"bytes"
"context"
"encoding/gob"
"fmt"
"os"
"time"