DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

原文链接

make file includes:

  • High-level, simple commands. Such as; compile start stop watch, etc.
  • Managing project-specific environment variables. It should inclide .env file.
  • Development-mode that auto-compiles on change.
  • Development-mode that shows compile error without verbosity around it.
  • Project-specific GOPATH, so I can keep dependencies in vendor folder.
  • Simplified file watching. e.g make watch run="go test ./..."

形成make的最终结果是:

1
2
3
4
5
6
7
8
9
10
11
$  make

Choose a command run in my-web-server:

install Install missing dependencies. Runs `go get` internally.
start Start in development mode. Auto-starts when code changes.
stop Stop development mode.
compile Compile the binary.
watch Run given command when code changes. e.g; make watch run="go test ./..."
exec Run given command, wrapped with custom GOPATH. e.g; make exec run="go test ./..."
clean Clean build files. Runs `go clean` internally.

makefile文件示例

环境设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
include .env

PROJECTNAME=$(shell basename "$(PWD)")

# Go related variables.
GOBASE=$(shell pwd)
GOPATH=$(GOBASE)/vendor:$(GOBASE):/home/azer/code/golang # You can remove or change the path after last colon.
GOBIN=$(GOBASE)/bin
GOFILES=$(wildcard *.go)

# Redirect error output to a file, so we can show it in development mode.
STDERR=/tmp/.$(PROJECTNAME)-stderr.txt

# PID file will store the server process id when it's running on development mode
PID=/tmp/.$(PROJECTNAME)-api-server.pid

# Make is verbose in Linux. Make it silent.
MAKEFLAGS += --silent

命令部分的设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
## exec: Run given command, wrapped with custom GOPATH. e.g; make exec run="go test ./..."
exec:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) $(run)

start:
bash -c "trap 'make stop' EXIT; $(MAKE) compile start-server watch run='make compile start-server'"

stop: stop-server

## watch: Run given command when code changes. e.g; make watch run="echo 'hey'"
watch:
@yolo -i . -e vendor -e bin -c $(run)

install: go-get

一些子命令的设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
compile:
@-touch $(STDERR)
@-rm $(STDERR)
@-$(MAKE) -s go-compile 2> $(STDERR)
@cat $(STDERR) | sed -e '1s/.*/\nError:\n/' | sed 's/make\[.*/ /' | sed "/^/s/^/ /" 1>&2

start-server:
@echo " > $(PROJECTNAME) is available at $(ADDR)"
@-$(GOBIN)/$(PROJECTNAME) 2>&1 & echo $$! > $(PID)
@cat $(PID) | sed "/^/s/^/ \> PID: /"

stop-server:
@-touch $(PID)
@-kill `cat $(PID)` 2> /dev/null || true
@-rm $(PID)

restart-server: stop-server start-server

一些其他命令的设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## clean: Clean build files. Runs `go clean` internally.
clean:
@(MAKEFILE) go-clean

go-compile: go-clean go-get go-build

go-build:
@echo " > Building binary..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build -o $(GOBIN)/$(PROJECTNAME) $(GOFILES)

go-generate:
@echo " > Generating dependency files..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go generate $(generate)

go-get:
@echo " > Checking if there is any missing dependencies..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get $(get)

go-install:
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go install $(GOFILES)

go-clean:
@echo " > Cleaning build cache"
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go clean

help部分的设置

1
2
3
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'

未来,到底是什么样子

远方,究竟有什么值得追寻


本周完成:

  • 工作的交接
  • spring boot 2.0部分

下周计划:

  • 新工作
  • 熟悉环境

告别了三年的新美,心中还是有些怅然,告别了舒适的环境,去迎向不可知的未来,心中还是有点不舍,不过,总是要跳出舒适区,去尝试一下挑战,尝试去向更厉害的人去学习。。

未来和远方,不是那么确定性,也没法像以前那么安逸了,不过一直保持学习的心态,总不会太差。。

经过了3年前那次临时的跳槽的话,这次应该也算比较成熟了,也不算初入创业公司的雏鸟了,心态上和工作上,应该会更成熟一些,学习的心态。。。嗯。。

或许刚开始的时候,就有点不平等吧,不管是自己还是家庭上,感觉还是没有那么门当户对,所以,还是安静地当个acer,安安静静做好自己能做好的,也不要有太多的奢求了。。。

工作上,进入一个新的方向,尽快地去熟悉和学习,加油。。。

时间安排上,还有提高的空间,以及相关的计划表部分,要重新梳理一下,按照计划来,相关的锻炼部分,跟上。。

虽然心中没法做到毫无畏惧,但保持学习的心态,也就无所谓了,只不过去见识一段新的征程,看风景,认识人,做事情,无外乎是于此。。。

原文链接

所有的编程语言都反映了语言设计者对编程哲学的反思,通常包括之前的语言所暴露的一些不足地方的改进

Go语言提供了基于CSP的并发特性支持

golang部分提供image

原文链接

git checkout — 这样子废弃掉本地的修改

undo local commit

1
2
git reset HEAD~2        # undo last two commits, keep changes
git reset --hard HEAD~2 # undo last two commits, discard changes

Remove a file from git without removing it from your file system

1
2
git reset filename          # or git rm --cached filename
echo filename >> .gitingore # add it to .gitignore to avoid re-adding it

git-amend 操作可以对commit message进行amend操作

Clean up local commits before pushing

1
2
3
4
git rebase --interactive 
# if you didn't specify any tracking information for this branch
# you will have to add upstream and remote branch information:
git rebase --interactive origin branch

原文链接

一切皆文件,包含

  • 一切都是字节流
  • 文件系统是统一的命名空间

文件路径可以引用几乎任何东西:文件系统、设备、网络共享或通信通道

伪文件系统?