摘要:
Channels can bebuffered. Provide the buffer length as the second argument tomaketo initialize a buffered channel:ch := make(chan int, 100)Sends to a b... 阅读全文
posted @ 2014-10-28 23:44
wuhn
阅读(199)
评论(0)
推荐(0)
摘要:
Channels are a typed conduit through which you can send and receive values with the channel operator,<-.ch <- v // Send v to channel ch.v := <-ch ... 阅读全文
posted @ 2014-10-28 23:40
wuhn
阅读(182)
评论(0)
推荐(0)
摘要:
The next section covers Go's concurrency primitives.A Tour of GoGoroutinesAgoroutineis a lightweight thread managed by the Go runtime.go f(x, y, z)sta... 阅读全文
posted @ 2014-10-28 23:32
wuhn
阅读(177)
评论(0)
推荐(0)
摘要:
/* Exercise: Loops and Functions #43 */package main import ( "fmt" "math") func Sqrt(x float64) float64 { z := float64(2.) s := float64(0)... 阅读全文
posted @ 2014-10-28 23:29
wuhn
阅读(790)
评论(0)
推荐(0)
摘要:
package mainimport ( "io" "os" "strings" "fmt")type rot13Reader struct { r io.Reader}func (rot13 rot13Reader)Read(p []byte) (n int, err... 阅读全文
posted @ 2014-10-28 23:27
wuhn
阅读(491)
评论(0)
推荐(0)
摘要:
Remember the picture generator you wrote earlier? Let's write another one, but this time it will return an implementation ofimage.Imageinstead of a sl... 阅读全文
posted @ 2014-10-28 23:09
wuhn
阅读(428)
评论(0)
推荐(0)
摘要:
Package imagedefines theImageinterface:package imagetype Image interface { ColorModel() color.Model Bounds() Rectangle At(x, y int) color.Col... 阅读全文
posted @ 2014-10-28 22:59
wuhn
阅读(137)
评论(0)
推荐(0)
摘要:
Implement the following types and define ServeHTTP methods on them. Register them to handle specific paths in your web server.type String stringtype S... 阅读全文
posted @ 2014-10-28 22:57
wuhn
阅读(465)
评论(0)
推荐(0)
摘要:
Package httpserves HTTP requests using any value that implementshttp.Handler:package httptype Handler interface { ServeHTTP(w ResponseWriter, r *Re... 阅读全文
posted @ 2014-10-28 22:47
wuhn
阅读(151)
评论(0)
推荐(0)
摘要:
Copy yourSqrtfunction from the earlier exercises and modify it to return anerrorvalue.Sqrtshould return a non-nil error value when given a negative nu... 阅读全文
posted @ 2014-10-28 20:41
wuhn
阅读(575)
评论(0)
推荐(0)
摘要:
An error is anything that can describe itself as an error string. The idea is captured by the predefined, built-in interface type,error, with its sing... 阅读全文
posted @ 2014-10-28 20:23
wuhn
阅读(140)
评论(0)
推荐(0)
摘要:
A type implements an interface by implementing the methods.There is no explicit declaration of intent.Implicit interfaces decouple implementation pack... 阅读全文
posted @ 2014-10-28 20:08
wuhn
阅读(251)
评论(0)
推荐(0)
摘要:
An interface type is defined by a set of methods.A value of interface type can hold any value that implements those methods.Note:The code on the left ... 阅读全文
posted @ 2014-10-28 20:00
wuhn
阅读(139)
评论(0)
推荐(0)
摘要:
Methods can be associated with a named type or a pointer to a named type.We just saw twoAbsmethods. One on the*Vertexpointer type and the other on the... 阅读全文
posted @ 2014-10-28 19:34
wuhn
阅读(279)
评论(0)
推荐(0)
摘要:
In fact, you can define a method onanytype you define in your package, not just structs.You cannot define a method on a type from another package, or ... 阅读全文
posted @ 2014-10-28 18:59
wuhn
阅读(124)
评论(0)
推荐(0)
摘要:
Go does not have classes. However, you can define methods on struct types.Themethod receiverappears in its own argument list between thefunckeyword an... 阅读全文
posted @ 2014-10-28 18:54
wuhn
阅读(118)
评论(0)
推荐(0)
摘要:
打开相机://先设定sourceType为相机,然后判断相机是否可用(ipod)没相机,不可用将sourceType设定为相片库 UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCa... 阅读全文
posted @ 2014-10-28 17:04
wuhn
阅读(197)
评论(0)
推荐(0)
摘要:
PhoneGap 和 Cordova的关系阐述是PhoneGap贡献给Apache后的开源项目,是从PhoneGap中抽出的核心代码,是驱动PhoneGap的核心引擎。你可以把他想象成类似于Webkit和Google Chrome的关系。Apache Cordova is an open-sourc... 阅读全文
posted @ 2014-10-28 15:39
wuhn
阅读(215)
评论(0)
推荐(0)
摘要:
To Install, ensure that you have NodeJS installed, then open your commandline and run the following:$ sudo npm install -g phonegap Once ins... 阅读全文
posted @ 2014-10-28 15:32
wuhn
阅读(174)
评论(0)
推荐(0)
摘要:
In my app, I am loading a resource heavy view that takes about 1 to 2 seconds to load. So I am loading it in a separate thread like this:hud = [[MBPro... 阅读全文
posted @ 2014-10-28 10:12
wuhn
阅读(367)
评论(0)
推荐(1)
摘要:
The next group of slides covers methods and interfaces, the constructs that define objects and their behavior. 阅读全文
posted @ 2014-10-28 07:56
wuhn
阅读(136)
评论(0)
推荐(0)
摘要:
Let's explore Go's built-in support for complex numbers via thecomplex64andcomplex128types. For cube roots, Newton's method amounts to repeating:Find ... 阅读全文
posted @ 2014-10-28 07:54
wuhn
阅读(153)
评论(0)
推荐(0)
摘要:
Switch without a condition is the same asswitch true.This construct can be a clean way to write long if-then-else chains.package main import ( "fmt... 阅读全文
posted @ 2014-10-28 07:38
wuhn
阅读(183)
评论(0)
推荐(0)
摘要:
Switch cases evaluate cases from top to bottom, stopping when a case succeeds.(For example,switch i {case 0:case f():}does not callfifi==0.)Note:Time ... 阅读全文
posted @ 2014-10-28 07:35
wuhn
阅读(228)
评论(0)
推荐(0)
摘要:
You probably knew whatswitchwas going to look like.A case body breaks automatically, unless it ends with afallthroughstatement.package main import ( ... 阅读全文
posted @ 2014-10-28 00:10
wuhn
阅读(170)
评论(0)
推荐(0)

浙公网安备 33010602011771号