Here will be a top to bottom question and answer for HAv2!
How does a simple counter app look in V2?
app({| package main | |
| import ( | |
| "encoding/hex" | |
| "log" | |
| "strconv" | |
| "strings" | |
| "github.com/jacobsa/go-serial/serial" | |
| ) |
| #!/usr/bin/env bash | |
| set -ex | |
| sudo apt update | |
| git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.6.1 | |
| echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc | |
| echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc |
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| "math/rand" | |
| "os" | |
| "strings" | |
| "sync" | |
| ) |
| const fileString = "title,body\nhello,wow\nwow,ok"; | |
| const csv = fileString.split('\n'); | |
| console.log(csv); | |
| const headers = csv[0].split(','); | |
| const rows = csv.splice(1); |
| package main | |
| import ( | |
| "fmt" | |
| "math/rand" | |
| "strings" | |
| "sync" | |
| ) | |
| func main() { |
| switch runtime.GOOS { | |
| case "darwin": | |
| exec.Command("open", "http://localhost:8792").Run() | |
| break | |
| case "windows": | |
| exec.Command("cmd.exe", "/C", "start "+"http://localhost:8792").Run() | |
| break | |
| default: | |
| cmd := exec.Command("xdg-open", "http://localhost:8792") |
| parse_git_branch() { | |
| git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
| } | |
| export PS1="\W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ " |
1953282128707757731632014947596256332443542996591873396953405194571625257887015694766641987634150146128879524335220236084625510912019560233744015438115196636156919962125642894303370113827800638002767411527927466669865578379318822832061271497583230334854893489572599230722912901928209264331627521730861460017912582042699659936020959339202005184862028402447343139811367418720203868480175318538621112878108240617741383293554561687606454065125954718029126547942894036981659206361019359291352135410376799082940320155702716115395031975973247782162957631629653356694777663285062345245593460647575025935813443457816767646258788590113727299073729478511448089572456191503507025589529116868550008802013233458747217794781447546792016090170642585629359747546532757575740077432034913428785189795354304734560307765078938767286539166799232817449361991523768149557632085371047859706188438731530582395627560879063107819004975169594709736713891745704555202135123350794403360712030504144685221041565037321067932275625864751191461141736034968121