This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
| #!/bin/bash | |
| #This script creates 1 master, 2 slaves and 3 sentinels services in docker swarm. | |
| docker network create \ | |
| --driver overlay \ | |
| testes_network | |
| SWARM_MASTER=192.168.205.125 | |
| #Master |
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net" | |
| ) | |
| func main() { | |
| cnames, addrs, err := net.LookupSRV("_salty", "_tcp", "home.arpa") |
| --- | |
| version: "3.8" | |
| services: | |
| seed: | |
| image: consul:latest | |
| environment: | |
| - "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}" | |
| - "CONSUL_BIND_INTERFACE=eth0" | |
| entrypoint: |
| --- | |
| version: "3.8" | |
| services: | |
| master: | |
| image: chrislusf/seaweedfs:latest | |
| command: master -mdir=/data | |
| networks: | |
| - weed |
| module twtxt-search-engine | |
| go 1.14 | |
| require ( | |
| github.com/gocolly/colly/v2 v2.1.0 | |
| github.com/jointwt/twtxt v0.0.0-20210108082814-7098fcfa49df | |
| github.com/prologic/read-file-last-line v0.0.0-20200806014221-326f63458987 | |
| github.com/sirupsen/logrus v1.7.0 | |
| ) |
This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
| # First try, we get edb8f4a65586 as our hash | |
| $ cat << EOF | docker build --no-cache - | |
| > FROM alpine | |
| > RUN touch foo | |
| > EOF | |
| Sending build context to Docker daemon 2.048kB | |
| Step 1/2 : FROM alpine | |
| ---> a24bb4013296 | |
| Step 2/2 : RUN touch foo | |
| ---> Running in 9687f21f4edb |
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "net/http" | |
| "net/url" | |
| "os" |
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "os" | |
| "runtime" | |
| "runtime/pprof" | |
| "strings" |
| version: '3.5' | |
| # WARNING: Haven't tested this version of this YAML exactly, but it *should* be correct. | |
| services: | |
| master-1: | |
| image: chrislusf/seaweedfs:latest | |
| networks: | |
| - hostnet | |
| command: "master -port=9333 -defaultReplication=001 -peers=localhost:9333,localhost:9334,localhost:9335" |