這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。(PS:專欄所有的代碼都是基於go version go1.8 darwin/amd64)流動的水沒有形狀,漂流的風找不到蹤跡,一切代碼都瞭然於心,我們在寫代碼的時候,總是有一種思維定式陪伴左右,在對事物做判斷的時候,往往這種思維定式會往正向或反向做推動作用,在開發的過程中如果不小心忽略,往往就是埋下了陷阱,以下代碼是大多數新手會遇到的坑,package mainimport ("fmt")type People
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。Go語言中byte和rune實質上就是uint8和int32類型。byte用來強調資料是raw data,而不是數字;而rune用來表示Unicode的code point。參考規範:uint8 the set of all unsigned 8-bit integers (0 to 255)int32 the set of all signed 32-bit integers (-2147483648
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。Go語言中http package包含Handle和HandleFunc兩個函數:func Handlefunc Handle(pattern string, handler Handler)Handle registers the handler for the given pattern in the DefaultServeMux. The documentation for ServeMux explains how
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。以下摘自The Go Programming Language:A const declaration gives names to constants, that is, values that are fixed at compile time. The value of a constant must be a number, string, or boolean.const的值只能是數字,字串或者布爾值。 A
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。以下摘自The Go Programming Language:The increment statement i++ adds 1 to i ; it’s equivalent to i += 1 which is in turn equivalent to i = i + 1 . There’s a corresponding decrement statement i– that subtracts 1. These
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。以下摘自The Go Programming Language:The import declarations must follow the package declaration.After that, a program consists of the declarations of functions, variables, constants, and types (introduced by the key
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。以下摘自The Go Programming Language:Package main is special. It defines a standalone executable program, not a library. Within package main the function main is also special—it’s where execution of the program begins.
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。在本地搭建k8s on Mesos項目時,Mesos client指令碼要以root身份運行。另外如果本地環境用到了proxy,一定要注意可能(不確定是否有例外,比如也許取決於你所使用的proxy或作業系統)需要把k8s或者Mesos的IP地址加入到no-proxy/NO_PROXY環境變數中。具體可參見下列issues:The kubernetes on Mesos can’t run successfully on the
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。以下摘自The Go Programming Language:When printing numbers using the fmt package, we can control the radix and format with the %d, %o, and %x verbs, as shown in this example:o := 0666fmt.Printf(“%d %[1]o %#[1]o\n”, o) // “