2.1 gofmt 的文化演变
4/21/2015 gofmt 的文化演变 http://127.0.0.1:3999/gofmt-cn.slide#1 1/34 gofmt 的文化演变 The Cultural Evolution of gofmt Robert Griesemer Google, Inc. 4/21/2015 gofmt 的文化演变 http://127.0.0.1:3999/gofmt-cn.slide#1 slide#1 2/34 gofmt Go源代码格式化工具 定义了“标准“格式 golang.org代码库中所有提交的Go代码都必须通过gofmt格式化过 除了gofmt之外,相同功能可以通过go/format库获得 不需要设置! 4/21/2015 gofmt 的文化演变 http://127.0.0.1:3999/gofmt-cn.slide#1 3/34 初衷 代码审查是软件工程的最佳实践 代码审查是基于代码规范和正规格式的 太多时间浪费在审查格式上而不是代码本身了 但是这工作对机器来说是最好不过了的 第一个决定就是要写一个好的格式美化器 4/21/2015 gofmt 的文化演变 http://127.0.0.1:3999/gofmt-cn.slide#1 4/34 历史 格式美化器和代码美化工具在计算机发展的早期就已出现 对于产生可读的Lisp代码很重要的: GRINDEF (Bill0 码力 | 34 页 | 9.97 MB | 1 年前3The Way To Go - 2012
go-programs with command- and Makefiles .........................35 3.5 Formatting code: go fmt or gofmt ...........................................................................39 3.6 Documenting code: compiler: When a program has been written (applying common naming- and style-rules), subject it to gofmt (see §3.5 to format it correctly), and then build (compile / link) it; if the build-process (which code formatting: If you append the following lines to Makefile: format: gofmt -w $(GOFILES) then gomake format will invoke gofmt on your source-files. 38 Ivo Balbaert Makefile in Windows: A Makefile0 码力 | 629 页 | 4.85 MB | 1 年前3Go 入门指南(The way to Go)
来跟踪代码执行过程(第 6.4 节)。 Go入门指南 - 23 - 本文档使用 看云 构建 3.4 构建并运行 Go 程序 在大多数 IDE 中,每次构建程序之前都会自动调用源码格式化工具 gofmt 并保存格式化后的源文件。如 果构建成功则不会输出任何信息,而当发生编译时错误时,则会指明源码中具体第几行出现了什么错误, 如: a declared and not used 。一般情况下,你可以双击 的开发时间,因此他们制作了一个工具: go fmt ( gofmt )。这个工具可以将你的源代码格式化成符合 官方统一标准的风格,属于语法风格层面上的小型重构。遵循统一的代码风格是 Go 开发中无可撼动的铁 律,因此你必须在编译或提交版本管理系统之前使用 gofmt 来格式化你的代码。 尽管这种做法也存在一些争论,但使用 gofmt 后你不再需要自成一套代码风格而是和所有人使用相同的 而不替换成空格。 在命令行输入 gofmt –w program.go 会格式化该源文件的代码然后将格式化后的代码覆盖原始内容 (如果不加参数 -w 则只会打印格式化后的结果而不重写文件); gofmt -w *.go 会格式化并重写所有 Go 源文件; gofmt map1 会格式化并重写 map1 目录及其子目录下的所有 Go 源文件。 gofmt 也可以通过在参数 -r 后面0 码力 | 380 页 | 2.97 MB | 1 年前3Go 入门指南(The way to Go)
调试器 3.3 调试器 - 42 - 本文档使用 书栈(BookStack.CN) 构建 3.4 构建并运行 Go 程序 在大多数 IDE 中,每次构建程序之前都会自动调用源码格式化工具 gofmt 并保存格式化后的源文件。如果构建 成功则不会输出任何信息,而当发生编译时错误时,则会指明源码中具体第几行出现了什么错误,如: a declared and not used 。一般情况下,你可以双击 间,因此他们制作了一个工具: go fmt ( gofmt )。这个工具可以将你的源代码格式化成符合官方统一标准的风 格,属于语法风格层面上的小型重构。遵循统一的代码风格是 Go 开发中无可撼动的铁律,因此你必须在编译或提交 版本管理系统之前使用 gofmt 来格式化你的代码。 尽管这种做法也存在一些争论,但使用 gofmt 后你不再需要自成一套代码风格而是和所有人使用相同的规则。这 而不替换成空格。 在命令行输入 gofmt –w program.go 会格式化该源文件的代码然后将格式化后的代码覆盖原始内容(如果不加参数 -w 则只会打印格式化后的结果而不重写文件); gofmt -w *.go 会格式化并重写所有 Go 源文件; gofmt map1 会格式化并重写 map1 目录及其子目录下的所有 Go 源文件。 gofmt 也可以通过在参数 -r0 码力 | 466 页 | 4.44 MB | 1 年前3deno handbook
piece of code, e.g. deno eval "console.log(1 + 2)" fmt a built-in code formatter (similar to gofmt in Go) help prints this message or the help of the given subcommand(s) info show info about One of the things I really liked from Go was the gofmt command that came with the Go compiler. All Go code looks the same. Everyone uses gofmt . 28 JavaScript programmers are used to running Prettier0 码力 | 46 页 | 4.11 MB | 1 年前3Build web application with Golang
project to Github. These are useful for local tests, but useless for version control. go fmt and gofmt The people who are working with C/C++ should know that people are always arguing about which code the command 'gofmt -l -w' on the packages named by the import paths. We usually use gofmt -w instead of go fmt . The latter will not rewrite your source files after formatting code. gofmt -w src formats code expression using F1 Function declaration jump using F2 Gdb support Auto-format with gofmt Others Multi-language Plugin system Text editor themes Syntax support based on Kate intelligent0 码力 | 327 页 | 1.63 MB | 1 年前3The Go Programming Language (Otc 30, 2009)
HTTP, RPC HTML (and more general) templates ...and lots more. Monday, November 2, 2009 Godoc and Gofmt Godoc: documentation server, analogous to javadoc but easier on the programmer. Can run yourself (top-level; serves all docs) http://golang.org/pkg/ (package docs) http://golang.org/src/ (source code) Gofmt: pretty-printer; all code in the repository has been formatted by it. Monday, November 2, 20090 码力 | 47 页 | 241.70 KB | 1 年前3Real World Go
formatter: gofmt. We never argued over where to put a curly-brace, tabs vs. spaces, or if we should align assignments. We simply agreed that the buck stopped at the default output from gofmt. " Why choose0 码力 | 49 页 | 595.19 KB | 1 年前3Go Web编程
这个功能其实 在底层就是调用了go fmt。接下来的一节我将讲述两个工具,这两个工具都自带了保存文件时自动化go fmt功能。 使用go fmt命令,更多时候是用gofmt,而且需要参数-w,否则格式化结果不会写入文件。gofmt -w src,可以格式 化整个项目。 go get go get 这个命令是用来动态获取远程代码包的,目前支持的有BitBucket、GitHub、Google Go语言的编辑支持 类浏览器和大纲显示 Gocode(代码自动完成工具)的完美支持 Go语言文档查看和Api快速检索 代码表达式信息显示F1 源代码定义跳转支持F2 Gdb断点和调试支持 gofmt自动格式化支持 其他特征 支持多国语言界面显示 完全插件体系结构 支持编辑器配色方案 基于Kate的语法显示支持 基于全文的单词自动完成 支持键盘快捷键绑定方案 Markdown文档编辑支持 (compile (concat "go run " (buffer-file-name)))) ;; helper function (defun go-fmt-buffer () "run gofmt on current buffer" (interactive) (if buffer-read-only (progn (ding) (message0 码力 | 295 页 | 5.91 MB | 1 年前3QCon北京2018-《未来都市--智慧城市与基于深度学习的机器视觉》-陈宇恒
- 比起C++,更易于实践各种并发模式 - 比起Java,更加简洁,更易于与C/C++交互 - 比起脚本语言,类型和内存安全,保证重构效率与产品质量 - 完善的配套工具,如go test, gofmt, go lint, race-detector Go语言在高性能系统中的实践经验 • Go在开发高性能应用上也有一些不足, 对比C++: - 无法直接控制操作系统线程,CUDA 调用需要特殊处理0 码力 | 23 页 | 9.26 MB | 1 年前3
共 31 条
- 1
- 2
- 3
- 4