作者:empty 页数:116 出版社:empty |
IntroductionGo is a new language.Although it borrows ideas from existing languages, it has unusualproperties that make effective Go programs different in character from programs written in itsrelatives.A straightforward translation of aC++or Java program into Go is unlikely toproduce a satisfactory result—Java programs are written in Java, not Go.On the other handthinking about the prlem from aGo perspective could produce a successful but quitedifferent program.In other words, to write Go wel, it's important to understand its propertiesand idioms.It's also important to know the established conventions for programming in Go,such as naming, formatting, program construction, and soon, so that programs you write wilbe easy for other Go programmers to understand.This document gives tips for w rng clear, idiomatic Go code.It augments the languagespecification, the Tour of Go, and Howto Write Go Code, all of which you should read first.
引言Go是一门全新的语言。尽管它从既有的语言中借鉴了许多理念·但其与众不同的特性·使得用Go编程在本质上就不同于其它语言·将现有的C++或Java程序直译为Go程序并不能令人满意——毕竟Java程序是用Java编写的·而不是Go。另一方面·若从Go的角度去分析问题·你就能编写出同样可行但大不相同的程序。换句话说·要想将Go程序写得好·就必须理解其特性和风格。了解命名、格式化、程序结构等既定规则也同样重要·这样你编写的程序才能更容易被其他程序员所理解。本文档就如何编写清晰、地道的Go代码提供了一些技巧·它是对语言规范、Go语言之旅以及如何使用Go编程的补充说明·因此我们建议您先阅读这些文档·Effective Go作为GO语言的入门必读教程·值得每位初学者好好阅读一遍·编辑成书·方便阅读交流