脚本:轻松在Go中编写类似shell的脚本

时间:2021-02-05 21:58:46
【文件属性】:
文件名称:脚本:轻松在Go中编写类似shell的脚本
文件大小:167KB
文件格式:ZIP
更新时间:2021-02-05 21:58:46
shell scripting first-timers easy beginner-friendly import github . com / bitfield / script 什么是script ? script是一个Go库,用于执行shell脚本擅长的那种任务:读取文件,执行子进程,计算行数,匹配字符串等。 为什么用Go编写系统管理程序不像在典型的Shell中那样容易? script旨在使其变得如此简单。 Shell脚本通常在数据流(管道)上构成一系列操作。 script也是如此。 我该怎么办? 让我们看一个简单的例子。 假设您想以字符串形式读取文件的内容: contents , err := script . File ( "test.txt" ). String ()
【文件预览】:
script-master
----pipes_test.go(4KB)
----testdata()
--------multiple_files()
--------bytes.bin(4B)
--------multiple_files_with_subdirectory()
--------freq.input.txt(110B)
--------last10.golden.txt(248B)
--------concat.golden.txt(95B)
--------first10.golden.txt(229B)
--------empty.txt(0B)
--------test.txt(84B)
--------column.input.txt(323B)
--------freq.golden.txt(40B)
--------sha256Sum.input.txt(26B)
--------column.golden.txt(29B)
--------first.input.txt(433B)
--------hello.txt(11B)
----pipes.go(2KB)
----read_auto_closer.go(1KB)
----sources.go(3KB)
----img()
--------fundamentals.png(44KB)
--------data.png(70KB)
----doc.go(199B)
----main_test.go(274B)
----.github()
--------FUNDING.yml(64B)
----read_auto_closer_test.go(653B)
----sinks.go(4KB)
----LICENSE(1KB)
----CONTRIBUTING.md(19KB)
----examples()
--------sha256sum()
--------cat()
--------head()
--------execute()
--------grep()
--------least_freq()
--------execforeach()
--------echo()
--------find()
--------slice()
--------visitors()
--------tail()
--------ls()
--------todo()
--------cat2()
----.gitignore(175B)
----filters_test.go(12KB)
----sinks_test.go(7KB)
----.circleci()
--------config.yml(183B)
----go.sum(348B)
----README.md(35KB)
----filters.go(11KB)
----go.mod(129B)
----sources_test.go(6KB)

网友评论