Skip to content

Instantly share code, notes, and snippets.

package main
import (
"context"
"log"
"os"
"time"
"golang.org/x/time/rate"
)
@suganoo
suganoo / intf1.go
Created February 8, 2019 09:54
Golang polymorphisim
package main
import "fmt"
type MainInterface interface {
call()
}
type HogeFunc func()
@suganoo
suganoo / embeded.go
Created February 1, 2019 10:01
interfaceの確認
package main
import (
"fmt"
)
type BaseDownloader struct {
}
type BaseUploader struct {
@suganoo
suganoo / 01 golangdb.go
Last active January 25, 2019 07:55
Go言語でDB操作
package main
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
)
var Db *sql.DB
@suganoo
suganoo / interval.go
Last active January 21, 2019 10:16
定期実行の理解
package main
import (
"fmt"
"os"
"os/signal"
"time"
)
func doSomething() {
@suganoo
suganoo / 01 time_pkg.go
Last active December 21, 2018 09:43
Tips of Tim pkg
package main
import (
"fmt"
"time"
"strconv"
)
func main() {
fmt.Println("----- Basic usage -----")
@suganoo
suganoo / pack_gz_files.go
Created December 13, 2018 04:08
concatenate gz files
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
)
func main() {
@suganoo
suganoo / 01 http_request.go
Created November 8, 2018 09:47
httpのrequest
package main
import (
"fmt"
"net/http"
)
func body(w http.ResponseWriter, r *http.Request){
len := r.ContentLength
body := make([]byte, len)
@suganoo
suganoo / 01 go_do_command.go
Last active November 6, 2018 09:30
Go で外部コマンド実行
package main
import (
"fmt"
"os/exec"
"time"
"strings"
)
func main() {
@suganoo
suganoo / 01 json_sample.json
Created October 17, 2018 09:37
Golangでjsonを扱う
{
"id" : 1,
"author" : "hogefuga",
"content" : "Hellooooooooo!!",
"comment" : {
"comment_id" : 11,
"message" : "very gooood"
},
"books" : [
{