This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Excluding first block | |
Let <- "let" // This is overrided by the following, same happens if i put this rule below the Identifier rule | |
Identifier <- ([a-z_]i+([a-z0-9_]i)*) { | |
return string(c.text), nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *Session) AddHandler(handler interface{}) func() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func handlerForInterface(handler interface{}) EventHandler { | |
switch v := handler.(type) { | |
case func(*Session, interface{}): | |
return interfaceEventHandler(v) | |
case func(*Session, *ChannelCreate): | |
return channelCreateEventHandler(v) | |
case func(*Session, *ChannelDelete): | |
return channelDeleteEventHandler(v) | |
case func(*Session, *ChannelPinsUpdate): | |
return channelPinsUpdateEventHandler(v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Why not | |
func Add<T>(addr *T, delta T) (new T) | |
otherInt32 := atomic.Add<int32>(&myInt32, 32) | |
// Instead of | |
func AddInt32(addr *int32, delta int32) (new int32) | |
otherInt32 := atomic.AddInt32(&myInt32, 32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Add<T>(addr *T, delta T) (new T) | |
func CompareAndSwap<T>(addr *T, old, new T) (swapped bool) | |
func Load<T>(addr *T) (val T) | |
func Store<T>(addr *T, val T) | |
func Swap<T>(addr *T, new T) (old T) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Map <KT, VT> struct { | |
iternalMap map[KT]VT | |
} | |
// mySyncMap := new(sync.Map<string, int>) | |
mySyncMap := &sync.Map<string, int>{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (m *Map) Delete(key m.KT) | |
func (m *Map) Load(key m.KT) (val m.KV, ok bool) | |
func (m *Map) LoadOrStore(key m.KT, val m.KV) (actual m.KV, loaded bool) | |
func (m *Map) Range(f func(key m.KT, val m.KV) bool) | |
func (m *Map) Store(key m.KT, val m.KV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Number<T> () T | |
func NumberN<T>(n T) T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// func Marshal(val interface{}) ([]byte, error) | |
data, err := json.Marshal(val) |
OlderNewer