Your SlideShare is downloading. ×
0
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Highlights of Go 1.1
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Highlights of Go 1.1

1,654

Published on

Talk on highlights of Go 1.1 presented at Golang London User Group, May 29, 2013.

Talk on highlights of Go 1.1 presented at Golang London User Group, May 29, 2013.

Published in: Technology
1 Comment
8 Likes
Statistics
Notes
No Downloads
Views
Total Views
1,654
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
19
Comments
1
Likes
8
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. www.cloudflare.com!Highlights of Go 1.1May 29, 2013John Graham-Cumming
  • 2. www.cloudflare.com!Method Values•  Function value bound to specific receivertype Prefixer struct {!prefix string!}!!func (p Prefixer) Add(s string) string {!return p.prefix + ": " + s!}!!func main() {!hawaii := Prefixer{"Aloha”}!fmt.Printf("%sn", hawaii.Add("Welcome to Honolulu"))!!adder := hawaii.Add!fmt.Printf("%sn", adder("Welcome to Honolulu"))!}!
  • 3. www.cloudflare.com!Change to return handling•  return statement not needed at end of functions iffunction termination is unambiguous•  Worth reading the specification on ‘terminatingstatements’•  http://golang.org/ref/spec#Terminating_statementsfunc even() int {!for {!if i := rand.Intn(100); i%2 == 0 {!return i!}!}!}!
  • 4. www.cloudflare.com!bufio.Scanner•  Simple, fast type for doing command tasks like readingos.Stdin line by line, or reading word by word from afile•  Built in scanners for lines, words, characters and runes•  Can provide a custom scanner functionscanner := bufio.NewScanner(os.Stdin)!!for scanner.Scan() {!fmt.Println(scanner.Text()!}!!if err := scanner.Err(); err != nil {!// Handle error!}!
  • 5. www.cloudflare.com!Size of int•  On 64-bit platforms int and uint are now 64 bits•  Elsewhere they are 32-bits.•  Couple of consequences:•  If your code was relying on them being 32-bits then you may havetrouble•  Slice indexes are ints which means they can have 2 billionmembersx := ^uint32(0) !// x is 0xffffffff!i := int(x) !// i is -1 on 32-bit systems, !! ! !// 0xffffffff on 64-bit!fmt.Println(i)!
  • 6. www.cloudflare.com!Heap size and Platforms•  On 64-bit machines heap can now be tens of GB•  No change on 32-bit•  If you were running off tip in recent months you alreadyhad massive heaps•  Experimental support for: linux/arm, freebsd/arm,netbsd/386, amd64 and arm, openbsd/386 andamd64
  • 7. www.cloudflare.com!Nanosecond timing •  FreeBSD, Linux, NetBSD, OpenBSD, OS X time packagehas nanosecond precision•  time.Round and time.Truncate to round up/down tonearest multiples of any time.Durationt, _ := time.Parse("2006 Jan 02 15:04:05", "2012 Dec07 12:15:30.918273645")!trunc := []time.Duration{!time.Nanosecond, time.Microsecond,!time.Millisecond, time.Second,!2 * time.Second, time.Minute,!10 * time.Minute, time.Hour, !}!for _, d := range trunc {!fmt.Printf("t.Truncate(%6s) = %sn", d,t.Truncate(d).Format("15:04:05.999999999"))!}!
  • 8. www.cloudflare.com!Performance•  Claimed 30 to 40% performance increase over Go 1.0.3•  Best analysis by Dave Cheney:•  http://dave.cheney.net/2013/05/21/go-11-performance-improvements•  http://dave.cheney.net/2013/05/25/go-11-performance-improvements-part-2•  http://dave.cheney.net/2013/05/28/go-11-performance-improvements-part-3•  Dave’s summary: 30-40% performance increase is real
  • 9. www.cloudflare.com!Performance Highlights•  Code generation improvements across all three gccompilers•  Improvements to inlining•  Reduction in stack usage•  Parallel garbage collector. •  More precise garbage collection, which reduces the sizeof the heap, leading to lower GC pause times.•  New runtime scheduler; tight integration of the schedulerwith the net package•  Parts of the runtime and standard library have beenrewritten in assembly to take advantage of specific bulkmove or crypto instructions.
  • 10. www.cloudflare.com!Race Detector •  http://golang.org/doc/articles/race_detector.html•  Detects concurrent access by two goroutines to thesame variable where one access is write•  go build –race example.gofunc main() {!c := make(chan bool)!m := make(map[string]string)!!go func() {!m["1"] = "a" // First conflicting access.!c <- true!}()!!m["2"] = "b" // Second conflicting access.!<-c!}!
  • 11. www.cloudflare.com!Full release notes•  http://golang.org/doc/go1.1•  Go 1.1 is backwards compatible with Go 1.0.3•  Go 1.2 targeted for December 1

×