摘要:
We can use Reusltenum to do error handling type Result<V, E> { Err(E), Ok(V) } Example: // (): empty // uszie: just return a integre as error for demo 阅读全文
摘要:
pub enum Option2<T> { None, Some(T) } /** impl is similar to typescript a class with is_some method */ impl<T> Option2<T> { pub fn is_some(&self) -> b 阅读全文
摘要:
Go Enum package main type GoEnum = int const ( Foo GoEnum = iota Bar Baz ) func main() { } Typescript Enum enum TsEnum { Foo, Bar, Baz } Rust Enum enu 阅读全文
摘要:
Converts an observable to a promise by subscribing to the observable, and returning a promise that will resolve as soon as the first value arrives fro 阅读全文
摘要:
Hello World Let's create a simple Go server, first let's setup the server and do hello world // @filename: main.go package main import ( "fmt" "net/ht 阅读全文
摘要:
Vanilla Go includes Testing A test is a file with suffix_test.go You define functions with prefix Test and with an special signature receiving a *test 阅读全文
摘要:
So, let's say we have a function to fetch crypto currencies price: package main import ( "fmt" "sync" "project/api" ) func main() { go getCurrencyData 阅读全文
摘要:
A goroutine is the Go way of suing threads, we open a goroutine just by invoking any function with a go prefix. go functionCall() Goroutines can commu 阅读全文
摘要:
Go has a special indexing syntax that forms the basis of removing one or more elements from a slice. I will teach you this syntax and show you its var 阅读全文
摘要:
Panic recovery is a mechanism in Go that allows a program to handle unexpected errors (panics) gracefully. package main import ( "fmt" ) func mayPanic 阅读全文