python tarfile and go strings
parent
83029df884
commit
99c556307f
|
@ -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`:
|
||||
|
||||
|
|
|
@ -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))
|
||||
```
|
|
@ -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)
|
||||
```
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue