Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
k get pods k get ns |grep ns-name k get service k port-forward --address 10.0.0.1 service/name -n namespace/name 80:80 8080:8080 # merge multi config export KUBECONFIG=~/.kube/config:./kube-config-1.yaml kubectx config view --flatten > ~/.kube/config # list pods k get pods --all-namespaces |pod-name #log pod k logs -f pod-name -n namespace-name # scale k scale --replicas=3 pod-name # context & namespace kx context-name kn namespace-name
git clone https://git.ubuntu.com/ubuntu.git git st git ci -a -m'comment message' # reset local change, HARD git reset --hard # amend into last commit git commit --amend # merge some-br into current branch, squash git merge --squash some-br # restore file git restore path/to/some/file # checkout remote branch git fetch origin/test git checkout origin/test git checkout -b test origin/test # stash git stash git stash pop # git url redirect git config --global url."https://$(user):$(token)@github.com/username".insteadOf "https://github.com/username" git config --global url."https://api:xxx@github.com/".insteadOf "git@github.com:"
rebase
1
git rebase -i HEAD~n
进本交互编辑界面,提示如下:
1 2 3 4 5 6 7 8 9 10 11 12 13
pick f7f3f6d changed my name a bit pick 310154e updated README formatting and added blame pick a5f4a0d added cat-file
# Rebase 710f0f8..a5f4a0d onto 710f0f8 # # Commands: # p, pick = use commit # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted.
修改后边的两个pick为squash,可以将这三个commit合为一个提交:
1 2 3 4 5 6 7 8 9 10 11 12 13
pick f7f3f6d changed my name a bit squash 310154e updated README formatting and added blame squash a5f4a0d added cat-file
# Rebase 710f0f8..a5f4a0d onto 710f0f8 # # Commands: # p, pick = use commit # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted.
# this is builder FROM golang:1.18.0-buster as builder RUN apt-get update && apt-get install -y --no-install-recommends build-essential \ && rm -rf /var/lib/apt/lists/*
COPY . /sources RUNcd /sources && make build
FROM debian:buster-slim RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates libaio1 \ && rm -rf /var/lib/apt/lists/*
# up ifconfig en0 alias 10.0.0.10 netmask 0xFFFFFFFF up ifconfig en0 alias 10.0.0.11 netmask 0xFFFFFFFF up # down ifconfig en0 10.0.0.10 delete ifconfig en0 10.0.0.11 delete
Package embed provides access to files embedded in the running Go program.
Go source files that import “embed” can use the //go:embed directive to initialize a variable of type string, []byte, or FS with the contents of files read from the package directory or subdirectories at compile time.
1 2 3 4 5
import _ "embed"
//go:embed hello.txt var s string print(s)
1 2 3 4 5
import _ "embed"
//go:embed hello.txt var b []byte print(string(b))
1 2 3 4 5 6
import"embed"
//go:embed hello.txt var f embed.FS data, _ := f.ReadFile("hello.txt") print(string(data))
embeded files must under current folder. any file outside current folder will fail, for example /root/somefile will not work.
"go:embed image/*" embeds all files under image/, including all file start with .dot and _underscore.
* will not recursive sub folders. so .dotfile and _underscore will not be embeded with image/subfolder/ sub folder.
"go:embed image/" or "go:embed image" embeds all file but ignored which start with .dot and _underscore.
symbolic links are not followed.
1 2 3 4 5 6 7 8 9 10 11
// embed multi files into a single filesystem //go:embed image/* template/* //go:embed html/index.html var content embed.FS
//go:embed image template html/index.html var content embed.FS
// embed files with space //go:embed "he llo.txt" var content embed.FS
Example with http-fileserver:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import ( "embed" "log" "net/http" )
//go:embed internal/embedtest/testdata/*.txt var content embed.FS