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
// Go Playground: https://go.dev/play/p/DMiZPwRUGWD | |
// time: O(N) | |
// space: O(1) | |
// why: Just For Fun! 🤪 | |
package main | |
import "fmt" | |
type Node struct { | |
V string |
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
// 🎄🎄🎄🎄🎄🎄🎄🦌🦌🦌🦌🦌🦌🦌🦌🦌🎅🏻🎁🎁🎁🎄🎄🎄🎄 | |
// time: O(N) | |
// space: O(1) | |
// Go Playground: https://go.dev/play/p/1g8m82vmuuu | |
// why: Merry Christmas! | |
package main | |
import "fmt" | |
type Node struct { |
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
// https://go.dev/play/p/RKU8IstAlhf | |
// Does close() signals select? Yes | |
// Is channel picked randomly? Yes | |
// If there is long buffered channel with many entries will cancel() / other channel be triggered? Yes | |
package main | |
import ( | |
"fmt" | |
"time" | |
) |
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
// I am applying function on two things and they tell me how 🐁 | |
// https://go.dev/play/p/8iGGh8Tebgw | |
package main | |
import "fmt" | |
type Summer interface { | |
Sum(other Summer) Summer | |
} |
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
// format string slice strings with whitespace can collide 🤪 | |
// https://go.dev/play/p/EqnE9ZWHcjh | |
package main | |
import "fmt" | |
func main() { | |
fmt.Printf("%v\n", []string{"a b", "c"}) | |
fmt.Printf("%v\n", []string{"a", "b", "c"}) |
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
// https://go.dev/play/p/oyMTzj-WQRq | |
package main | |
import "fmt" | |
func main() { | |
x := "" | |
if x != "" { | |
panic("no.way.") | |
} |
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 ( | |
"errors" | |
"fmt" | |
"unsafe" | |
) | |
type Currency uint8 |
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
// https://go.dev/play/p/mcWx20GtkaO | |
// 🌊 | |
package main | |
import "fmt" | |
type SGD int64 | |
func (as SGD) Add(bs SGD) SGD { return as + bs } |
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
// https://go.dev/play/p/0bbwnZYMKSa | |
// go@v1.19 does not recognize two wrapped errors | |
// go@v1.20 recognizes two wrapped errors | |
package main | |
import ( | |
"errors" | |
"fmt" | |
) |
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
// https://google.github.io/comprehensive-rust/basic-syntax/scopes-shadowing.html | |
fn main() { | |
let a = 10; | |
println!("before: {a}"); | |
{ | |
let a = "hello"; | |
println!("inner scope: {a}"); | |
let a = true; |
OlderNewer