Here's the simplest example showing how to do functional options in Golang.
They're a great way to enable users to set options and ease adding new options later.
package main
import (
"flag"
"fmt"
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
) | |
func main() { |
Testing Functions for Go | |
======================== | |
Below is a small collection of testing functions for Go. You don't need to import this as a dependency. Just copy these to your project as needed. | |
No, seriously. They're tiny functions. Just copy them. | |
```go | |
import ( |
# Add the following 'help' target to your Makefile | |
# And add help text after each target name starting with '\#\#' | |
help: ## Show this help. | |
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | |
# Everything below is an example | |
target00: ## This message will show up when typing 'make help' | |
@echo does nothing |
Here's the simplest example showing how to do functional options in Golang.
They're a great way to enable users to set options and ease adding new options later.
package main
import (
"flag"
"fmt"
Here's the simplest example showing how to do functional options in Golang.
They're a great way to enable users to set options and ease adding new options later.
package main
import (
"flag"
"fmt"
curl -s https://myurl.com/script.sh | bash /dev/stdin param1 param2 |
#!/bin/bash | |
declare -i f=75 s=13 r=2000 t=0 c=1 n=0 l=0 | |
declare -ir w=$(tput cols) h=$(tput lines) | |
declare -i x=$((w/2)) y=$((h/2)) | |
declare -ar v=( [00]="\x83" [01]="\x8f" [03]="\x93" | |
[10]="\x9b" [11]="\x81" [12]="\x93" | |
[21]="\x97" [22]="\x83" [23]="\x9b" | |
[30]="\x97" [32]="\x8f" [33]="\x81" ) | |
OPTIND=1 |
#!/bin/sh | |
sudo docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer |
Evar ( | |
concurrent = 5 | |
semaphoreChan = make(chan struct{}, concurrent) | |
) | |
func doWork(item int) { | |
semaphoreChan <- struct{}{} // block while full | |
go func() { | |
defer func() { | |
<-semaphoreChan // read to release a slot |
package main | |
import ( | |
"context" | |
"fmt" | |
"io" | |
"os" | |
"github.com/docker/docker/api/types" | |
"github.com/docker/docker/api/types/container" |