diff --git a/src/Development/Go/README.md b/src/Development/Go/README.md index 8b16745..077bb13 100644 --- a/src/Development/Go/README.md +++ b/src/Development/Go/README.md @@ -1,9 +1,9 @@ # Go -| Distribution | Package | -| ------------ | ----------------------------------------------- | -| Arch Linux | `go`, `go-tools` | -| Ubuntu | [See](https://github.com/golang/go/wiki/Ubuntu) | +| Distribution | Package | +| ------------ | ---------------- | +| Arch Linux | `go`, `go-tools` | +| Snap | `go` | Add to `~/.bashrc`: diff --git a/src/Development/Go/strings.md b/src/Development/Go/strings.md new file mode 100644 index 0000000..64a3cf6 --- /dev/null +++ b/src/Development/Go/strings.md @@ -0,0 +1,9 @@ +# [strings](https://golang.org/pkg/strings/) + +Replace list of strings by using Replacer: + +```go +template := "My city is {city} and my country is {country}" +r := strings.NewReplacer("{city}", "Sai Gon", "{country}", "Viet Nam") +fmt.Println(r.Replace(template)) +``` diff --git a/src/Development/Python/tarfile.md b/src/Development/Python/tarfile.md new file mode 100644 index 0000000..565290b --- /dev/null +++ b/src/Development/Python/tarfile.md @@ -0,0 +1,11 @@ +# [tarfile](https://docs.python.org/3/library/tarfile.html) + +```python +# Read then extract +with tarfile.open(path_to_tarfile) as tar: + tar.extractall(path_to_extract) + +# Create a gzipped archive from file +with tarfile.open(path_to_archive, "w:gz") as tar: + tar.add(path_to_file, arcname=filename_inside_archive) +``` diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 931dbf8..ca96ec1 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -42,6 +42,7 @@ - [ANTLR](Development/ANTLR/README.md) - [Condition](Development/ANTLR/Condition.md) - [Go](Development/Go/README.md) + - [strings](Development/Go/strings.md) - [testing](Development/Go/testing.md) - [time](Development/Go/time.md) - [Python](Development/Python/README.md) @@ -49,6 +50,7 @@ - [black](Development/Python/black.md) - [subprocess](Development/Python/subprocess.md) - [venv](Development/Python/venv.md) + - [tarfile](Development/Python/tarfile.md) - [Services](Development/Services/README.md) - [Consul](Development/Services/Consul.md) - [Grafana](Development/Services/Grafana.md)