Skip to content

Instantly share code, notes, and snippets.

@sugilog
sugilog / config.abc.json
Created March 17, 2017 05:22
Switch Config by arg at package.json for npm run.
{
"a" : 1,
"b" : 2,
"c" : 3
}
@sugilog
sugilog / concurLoop.go
Created December 2, 2016 05:36
同時実行数制限付きでループを並列処理する。
package main
import (
"fmt"
"sync"
"time"
)
func main() {
log(-1, -1)
@sugilog
sugilog / stdout.go
Last active July 25, 2016 01:46
Stdout
package main
import(
"fmt"
)
func main() {
chars := []string{
"A", "B", "C", "D", "E", "F", "G",
"L", "M", "Z",
@sugilog
sugilog / json.go
Created November 24, 2015 07:23
Treat JSON
package main
import (
"fmt"
"encoding/json"
)
func main() {
var parsed map[ string ]interface{}
jsonString := []byte( `{"a":"hoge","b":1.234}` )
@sugilog
sugilog / sample.go
Created January 31, 2015 09:07
Channelsのselect
package main
import (
"fmt"
"time"
)
const CAP = 20
func main() {
@sugilog
sugilog / overflow.go
Created January 31, 2015 08:29
整数のオーバーフローとラップアラウンド
package main
import "fmt"
func main() {
fmt.Println( "overflowIntWithLiteral" )
overflowIntWithLiteral()
fmt.Println( "overflowInt" )
overflowInt()
@sugilog
sugilog / sample1.go
Created January 24, 2015 16:36
Channelsのcloseとrange
package main
import (
"fmt"
)
func fibonacci(n int, c chan int) {
x, y := 0, 1
for i := 0; i < n; i++ {
@sugilog
sugilog / sample.go
Created January 24, 2015 16:10
バッファ
package main
import (
"fmt"
)
func main() {
channel := make( chan int, 2 )
fmt.Println( "before send" )
@sugilog
sugilog / sample.go
Created January 24, 2015 14:31
Goroutines:Channels
package main
import (
"fmt"
"time"
)
func ccounter( step int, channel chan int ) {
sum := 0
@sugilog
sugilog / sample.go
Created January 24, 2015 14:12
Goroutines:ポインタ
package main
import (
"fmt"
"time"
)
func pcounter( index int, count *int ) {
for i := 0; i < 5; i++ {
*count++