Compare commits

..

13 Commits

Author SHA1 Message Date
Rick Hudson
1d4942afe0 [dev.garbage] runtime: determine if an object is public
ROC (request oriented collector) needs to determine
if an object is visible to other goroutines, i.e.
public. In a later CL this will be used by the write
barrier and the publishing logic to distinguish between
local and public objects and act accordingly.

Change-Id: I6a80da9deb21f57e831a2ec04e41477f997a8c33
Reviewed-on: https://go-review.googlesource.com/25056
Reviewed-by: Austin Clements <austin@google.com>
2017-05-25 18:05:53 +00:00
Austin Clements
8b25a00e6d Merge branch 'master' into dev.garbage
Change-Id: I36274cf72b8e1908efc8e375cab7880d7b0b3f43
2017-01-11 11:34:07 -05:00
Austin Clements
42afbd9e63 Merge branch 'master' into dev.garbage
Sync to 1.8 beta 1.

Change-Id: Iddd3773babd8fe50aed791ef7150d0c7c455cc8d
2016-12-05 12:15:50 -05:00
Austin Clements
f9f6c90ed1 [dev.garbage] Merge branch 'master' into dev.garbage
This merges master as of the Go 1.7 release.

Change-Id: I95ac0f96a0837173a2b8d7e8aaadf6fecc1baeaf
2016-08-25 11:55:08 -04:00
Rick Hudson
69161e279e [dev.garbage] runtime: Add GODEBUG=gcroc=n
Add command line boilerplace that turns the ROC algorithm on.
gcroc=0 or not specified:
	does not turn ROC on but some benign code may run.
gcroc=1
	simply turns the algorithm on
gcroc>1
	same as gcroc but with increasing levels of diagnostics
	being turned on. Expect gcroc>1 to not be as performant as
	gcroc=1

Change-Id: I6348b6768f7a3f8c2f69ef01ea20efebf992029e
Reviewed-on: https://go-review.googlesource.com/21368
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-07-26 13:21:53 +00:00
Austin Clements
fb4c718209 [dev.garbage] Merge branch 'master' into dev.garbage
Change-Id: I8ba4b012d82921f9521f471b1c0b5a1f6149a986
2016-07-19 17:54:41 -04:00
Austin Clements
81b74bf9c5 [dev.garbage] runtime: make _TinySizeClass an int8 to prevent use as spanClass
Currently _TinySizeClass is untyped, which means it can accidentally
be used as a spanClass (not that I would know this from experience or
anything). Make it an int8 to avoid this mix up.

Change-Id: I1e69eccee436ea5aa45e9a9828a013e369e03f1a
Reviewed-on: https://go-review.googlesource.com/24372
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-06-23 16:26:08 +00:00
Austin Clements
edb54c300f [dev.garbage] runtime: eliminate heapBitsSetTypeNoScan
It's no longer necessary to maintain the bitmap of noscan objects
since we now use the span metadata to determine that they're noscan
instead of the bitmap.

The combined effect of segregating noscan spans and the follow-on
optimizations is almost no effect on the go1 benchmarks and a 1.19%
improvement in the garbage benchmark:

name              old time/op  new time/op  delta
XBenchGarbage-12  2.13ms ± 2%  2.11ms ± 1%  -1.19%  (p=0.000 n=19+20)

name                      old time/op    new time/op    delta
BinaryTree17-12              2.42s ± 1%     2.41s ± 1%  -0.50%  (p=0.001 n=20+17)
Fannkuch11-12                2.14s ± 0%     2.12s ± 0%  -0.91%  (p=0.000 n=20+17)
FmtFprintfEmpty-12          45.2ns ± 0%    45.2ns ± 1%    ~     (p=0.677 n=16+19)
FmtFprintfString-12          131ns ± 0%     132ns ± 1%  +0.57%  (p=0.000 n=16+20)
FmtFprintfInt-12             126ns ± 1%     126ns ± 0%    ~     (p=0.078 n=18+16)
FmtFprintfIntInt-12          199ns ± 0%     195ns ± 0%  -2.19%  (p=0.000 n=14+20)
FmtFprintfPrefixedInt-12     196ns ± 1%     196ns ± 0%    ~     (p=0.155 n=19+16)
FmtFprintfFloat-12           254ns ± 0%     253ns ± 0%  -0.50%  (p=0.000 n=14+19)
FmtManyArgs-12               803ns ± 1%     798ns ± 0%  -0.71%  (p=0.000 n=18+19)
GobDecode-12                7.11ms ± 1%    7.07ms ± 1%  -0.50%  (p=0.024 n=18+19)
GobEncode-12                5.87ms ± 0%    5.86ms ± 1%    ~     (p=0.113 n=19+20)
Gzip-12                      218ms ± 1%     218ms ± 1%    ~     (p=0.879 n=19+20)
Gunzip-12                   37.2ms ± 0%    37.3ms ± 0%  +0.14%  (p=0.047 n=19+20)
HTTPClientServer-12         80.5µs ± 6%    82.8µs ± 8%  +2.91%  (p=0.008 n=19+20)
JSONEncode-12               15.4ms ± 1%    15.4ms ± 1%  -0.32%  (p=0.003 n=18+19)
JSONDecode-12               55.1ms ± 1%    53.0ms ± 1%  -3.87%  (p=0.000 n=18+20)
Mandelbrot200-12            4.08ms ± 1%    4.10ms ± 1%  +0.34%  (p=0.001 n=19+17)
GoParse-12                  3.20ms ± 1%    3.21ms ± 1%    ~     (p=0.138 n=19+19)
RegexpMatchEasy0_32-12      70.6ns ± 2%    70.4ns ± 2%    ~     (p=0.343 n=20+20)
RegexpMatchEasy0_1K-12       240ns ± 0%     242ns ± 2%  +0.88%  (p=0.000 n=15+20)
RegexpMatchEasy1_32-12      70.5ns ± 1%    70.2ns ± 3%    ~     (p=0.053 n=18+20)
RegexpMatchEasy1_1K-12       374ns ± 1%     374ns ± 1%    ~     (p=0.705 n=20+19)
RegexpMatchMedium_32-12      108ns ± 1%     108ns ± 1%    ~     (p=0.854 n=20+19)
RegexpMatchMedium_1K-12     33.5µs ± 1%    33.6µs ± 2%    ~     (p=0.897 n=18+20)
RegexpMatchHard_32-12       1.76µs ± 1%    1.75µs ± 1%    ~     (p=0.771 n=18+18)
RegexpMatchHard_1K-12       52.8µs ± 1%    52.8µs ± 1%    ~     (p=0.678 n=17+19)
Revcomp-12                   381ms ± 1%     380ms ± 0%    ~     (p=0.320 n=20+16)
Template-12                 65.6ms ± 1%    65.1ms ± 2%  -0.75%  (p=0.003 n=20+20)
TimeParse-12                 324ns ± 1%     326ns ± 1%  +0.72%  (p=0.000 n=18+18)
TimeFormat-12                342ns ± 0%     343ns ± 1%  +0.22%  (p=0.004 n=15+18)
[Geo mean]                  52.4µs         52.3µs       -0.18%

Change-Id: Ic77faaa15cdac3bfbbb0032dde5c204e05a0fd8e
Reviewed-on: https://go-review.googlesource.com/23702
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-06-15 21:17:15 +00:00
Austin Clements
312aa09996 [dev.garbage] runtime: eliminate heapBits.hasPointers
This is no longer necessary now that we can more efficiently consult
the span's noscan bit.

Change-Id: Id0b00b278533660973f45eb6efa5b00f373d58af
Reviewed-on: https://go-review.googlesource.com/23701
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-06-15 21:17:04 +00:00
Austin Clements
d491e550c3 [dev.garbage] runtime: separate spans of noscan objects
Currently, we mix objects with pointers and objects without pointers
("noscan" objects) together in memory. As a result, for every object
we grey, we have to check that object's heap bits to find out if it's
noscan, which adds to the per-object cost of GC. This also hurts the
TLB footprint of the garbage collector because it decreases the
density of scannable objects at the page level.

This commit improves the situation by using separate spans for noscan
objects. This will allow a much simpler noscan check (in a follow up
CL), eliminate the need to clear the bitmap of noscan objects (in a
follow up CL), and improves TLB footprint by increasing the density of
scannable objects.

This is also a step toward eliminating dead bits, since the current
noscan check depends on checking the dead bit of the first word.

This has no effect on the heap size of the garbage benchmark.

We'll measure the performance change of this after the follow-up
optimizations.

Change-Id: I13bdc4869538ece5649a8d2a41c6605371618e40
Reviewed-on: https://go-review.googlesource.com/23700
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-06-15 21:16:53 +00:00
Austin Clements
641c32dafa [dev.garbage] Merge branch 'master' into dev.garbage
Change-Id: I7ab2afca656e8c145804d9823cd084b8a85bccd7
2016-06-06 10:01:41 -04:00
Austin Clements
2e495a1df6 [dev.garbage] Merge branch 'master' into dev.garbage
Change-Id: I35edefb4464566601850081ecc84dd3535d60ceb
2016-05-16 14:29:53 -04:00
Austin Clements
344476d23c [dev.garbage] Merge branch 'master' into dev.garbage
Change-Id: I2e04fd9e7071efe33ce76f2f10a8dbde53ba90b9
2016-05-09 14:49:54 -04:00
2060 changed files with 92392 additions and 248173 deletions

View File

@@ -7,7 +7,6 @@ Please answer these questions before submitting your issue. Thanks!
### What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

6
.gitignore vendored
View File

@@ -31,9 +31,9 @@ _testmain.go
/pkg/
/src/*.*/
/src/cmd/cgo/zdefaultcc.go
/src/cmd/go/internal/cfg/zdefaultcc.go
/src/cmd/go/internal/cfg/zosarch.go
/src/cmd/internal/objabi/zbootstrap.go
/src/cmd/go/zdefaultcc.go
/src/cmd/go/zosarch.go
/src/cmd/internal/obj/zbootstrap.go
/src/go/build/zcgo.go
/src/go/doc/headscan
/src/runtime/internal/sys/zversion.go

90
AUTHORS
View File

@@ -24,7 +24,6 @@ Ahmed Waheed Moanes <oneofone@gmail.com>
Ahmy Yulrizka <yulrizka@gmail.com>
Aiden Scandella <ai@uber.com>
Ainar Garipov <gugl.zadolbal@gmail.com>
Aishraj Dahal <aishraj@users.noreply.github.com>
Akihiro Suda <suda.kyoto@gmail.com>
Akshat Kumar <seed@mail.nanosouffle.net>
Alan Shreve <alan@inconshreveable.com>
@@ -61,7 +60,6 @@ Alexandre Fiori <fiorix@gmail.com>
Alexandre Normand <alexandre.normand@gmail.com>
Alexei Sholik <alcosholik@gmail.com>
Alexey Borzenkov <snaury@gmail.com>
Alexey Neganov <neganovalexey@gmail.com>
Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
Aliaksandr Valialkin <valyala@gmail.com>
Alif Rachmawadi <subosito@gmail.com>
@@ -77,7 +75,6 @@ Andrei Korzhevskii <a.korzhevskiy@gmail.com>
Andrei Vieru <euvieru@gmail.com>
Andrew Austin <andrewaclt@gmail.com>
Andrew Balholm <andybalholm@gmail.com>
Andrew Benton <andrewmbenton@gmail.com>
Andrew Bonventre <andybons@chromium.org>
Andrew Bursavich <abursavich@gmail.com>
Andrew Ekstedt <andrew.ekstedt@gmail.com>
@@ -129,11 +126,9 @@ awaw fumin <awawfumin@gmail.com>
Ayanamist Yang <ayanamist@gmail.com>
Aymerick Jéhanne <aymerick@jehanne.org>
Baiju Muthukadan <baiju.m.mail@gmail.com>
Bartosz Grzybowski <melkorm@gmail.com>
Ben Burkert <ben@benburkert.com>
Ben Lubar <ben.lubar@gmail.com>
Ben Olive <sionide21@gmail.com>
Ben Shi <powerman1st@163.com>
Benjamin Black <b@b3k.us>
Benny Siegert <bsiegert@gmail.com>
Benoit Sigoure <tsunanet@gmail.com>
@@ -156,28 +151,20 @@ Brian Gitonga Marete <marete@toshnix.com> <bgmarete@gmail.com>
Brian Kennedy <btkennedy@gmail.com>
Brian Ketelsen <bketelsen@gmail.com>
Brian Smith <ohohvi@gmail.com>
Brian Starke <brian.starke@gmail.com>
Bryan Alexander <Kozical@msn.com>
Bryan Ford <brynosaurus@gmail.com>
Bulat Gaifullin <gaifullinbf@gmail.com>
Caine Tighe <arctanofyourface@gmail.com>
Caleb Spare <cespare@gmail.com>
Carl Chatfield <carlchatfield@gmail.com>
Carl Henrik Lunde <chlunde@ifi.uio.no>
Carl Johnson <me@carlmjohnson.net>
Carlisia Campos <carlisia@grokkingtech.io>
Carlo Alberto Ferraris <cafxx@strayorange.com>
Carlos Castillo <cookieo9@gmail.com>
Carlos Cirello <uldericofilho@gmail.com>
Carolyn Van Slyck <me@carolynvanslyck.com>
Case Nelson <case.nelson@gmail.com>
Casey Marshall <casey.marshall@gmail.com>
Cezar Sá Espinola <cezarsa@gmail.com>
ChaiShushan <chaishushan@gmail.com>
Charles L. Dorian <cldorian@gmail.com>
Charles Lee <zombie.fml@gmail.com>
Chew Choon Keat <choonkeat@gmail.com>
Chris Biscardi <chris@christopherbiscardi.com>
Chris Dollin <ehog.hedge@gmail.com>
Chris Farmiloe <chrisfarms@gmail.com>
Chris Hines <chris.cs.guy@gmail.com>
@@ -211,7 +198,6 @@ Cristian Staretu <unclejacksons@gmail.com>
Currant
Cyrill Schumacher <cyrill@schumacher.fm>
Damian Gryski <dgryski@gmail.com>
Damien Lespiau <damien.lespiau@gmail.com>
Dan Caddigan <goldcaddy77@gmail.com>
Dan Callahan <dan.callahan@gmail.com>
Dan Peterson <dpiddy@gmail.com>
@@ -239,7 +225,6 @@ David G. Andersen <dave.andersen@gmail.com>
David Howden <dhowden@gmail.com>
David Jakob Fritz <david.jakob.fritz@gmail.com>
David Leon Gil <coruus@gmail.com>
David NewHamlet <david@newhamlet.com>
David R. Jenni <david.r.jenni@gmail.com>
David Sansome <me@davidsansome.com>
David Stainton <dstainton415@gmail.com>
@@ -269,7 +254,6 @@ Dmitriy Shelenin <deemok@googlemail.com> <deemok@gmail.com>
Dmitry Chestnykh <dchest@gmail.com>
Dmitry Savintsev <dsavints@gmail.com>
Dmitry Yakunin <nonamezeil@gmail.com>
Dominic Green <dominicgreen1@gmail.com>
Dominik Honnef <dominik.honnef@gmail.com>
Donald Huang <don.hcd@gmail.com>
Donovan Hide <donovanhide@gmail.com>
@@ -283,7 +267,6 @@ Eden Li <eden.li@gmail.com>
Edward Muller <edwardam@interlix.com>
Egon Elbre <egonelbre@gmail.com>
Ehren Kret <ehren.kret@gmail.com>
Eitan Adler <lists@eitanadler.com>
Eivind Uggedal <eivind@uggedal.com>
Elias Naur <elias.naur@gmail.com>
Elliot Morrison-Reed <elliotmr@gmail.com>
@@ -305,21 +288,16 @@ Esko Luontola <esko.luontola@gmail.com>
Euan Kemp <euank@euank.com>
Evan Phoenix <evan@phx.io>
Evan Shaw <chickencha@gmail.com>
Evgeniy Polyakov <zbr@ioremap.net>
Ewan Chou <coocood@gmail.com>
Ewan Valentine <ewan.valentine89@gmail.com>
Fabian Wickborn <fabian@wickborn.net>
Fabrizio Milo <mistobaan@gmail.com>
Facebook, Inc.
Faiyaz Ahmed <ahmedf@vmware.com>
Fan Hongjian <fan.howard@gmail.com>
Fastly, Inc.
Fatih Arslan <fatih@arslan.io>
Fazlul Shahriar <fshahriar@gmail.com>
Fedor Indutny <fedor@indutny.com>
Felipe Oliveira <felipeweb.programador@gmail.com>
Felix Geisendörfer <haimuiba@gmail.com>
Filip Gruszczyński <gruszczy@gmail.com>
Filippo Valsorda <hi@filippo.io>
Firmansyah Adiputra <frm.adiputra@gmail.com>
Florian Uekermann <florian@uekermann-online.de>
@@ -339,10 +317,8 @@ Gary Burd <gary@beagledreams.com>
Gaurish Sharma <contact@gaurishsharma.com>
Gautham Thambidorai <gautham.dorai@gmail.com>
Geert-Johan Riemer <gjr19912@gmail.com>
Gengliang Wang <ltnwgl@gmail.com>
Geoffroy Lorieux <lorieux.g@gmail.com>
Georg Reinke <guelfey@gmail.com>
George Gkirtsou <ggirtsou@gmail.com>
George Shammas <george@shamm.as> <georgyo@gmail.com>
Gerasimos Dimitriadis <gedimitr@gmail.com>
Gideon Jan-Wessel Redelinghuys <gjredelinghuys@gmail.com>
@@ -354,7 +330,6 @@ Gordon Klaus <gordon.klaus@gmail.com>
Graham King <graham4king@gmail.com>
Graham Miller <graham.miller@gmail.com>
Greg Ward <greg@gerg.ca>
Gregory Man <man.gregory@gmail.com>
Guillaume J. Charmes <guillaume@charmes.net>
Guobiao Mei <meiguobiao@gmail.com>
Gustav Paul <gustav.paul@gmail.com>
@@ -368,7 +343,6 @@ Hariharan Srinath <srinathh@gmail.com>
Harley Laue <losinggeneration@gmail.com>
Harry Moreno <morenoh149@gmail.com>
Harshavardhana <hrshvardhana@gmail.com>
Hauke Löffler <hloeffler@users.noreply.github.com>
Håvard Haugen <havard.haugen@gmail.com>
Hector Chu <hectorchu@gmail.com>
Hector Martin Cantero <hector@marcansoft.com>
@@ -381,13 +355,10 @@ Hiroshi Ioka <hirochachacha@gmail.com>
Hitoshi Mitake <mitake.hitoshi@gmail.com>
Holden Huang <ttyh061@gmail.com>
Hong Ruiqi <hongruiqi@gmail.com>
Hongfei Tan <feilengcui008@gmail.com>
Hsin-Ho Yeh <yhh92u@gmail.com>
Hu Keping <hukeping@huawei.com>
Hugues Bruant <hugues.bruant@gmail.com>
Ian Gudger <ian@loosescre.ws>
IBM
Ibrahim AshShohail <ibra.sho@gmail.com>
Icarus Sparry <golang@icarus.freeuk.com>
Idora Shinatose <idora.shinatose@gmail.com>
Igneous Systems, Inc.
@@ -410,19 +381,16 @@ James David Chalfant <james.chalfant@gmail.com>
James Fysh <james.fysh@gmail.com>
James Gray <james@james4k.com>
James Meneghello <rawrz0r@gmail.com>
James Neve <jamesoneve@gmail.com>
James P. Cooper <jamespcooper@gmail.com>
James Schofield <james@shoeboxapp.com>
James Smith <jrs1995@icloud.com>
James Sweet <james.sweet88@googlemail.com>
James Toy <nil@opensesame.st>
James Whitehead <jnwhiteh@gmail.com>
Jamie Beverly <jamie.r.beverly@gmail.com>
Jamie Stackhouse <contin673@gmail.com>
Jamil Djadala <djadala@gmail.com>
Jan Berktold <jan@berktold.co>
Jan H. Hosang <jan.hosang@gmail.com>
Jan Mercl <0xjnml@gmail.com> <befelemepeseveze@gmail.com>
Jan Mercl <0xjnml@gmail.com>
Jan Mercl <befelemepeseveze@gmail.com>
Jan Newmarch <jan.newmarch@gmail.com>
Jan Ziak <0xe2.0x9a.0x9b@gmail.com>
Jani Monoses <jani.monoses@ubuntu.com>
@@ -458,7 +426,6 @@ Joe Shaw <joe@joeshaw.org>
Joe Sylve <joe.sylve@gmail.com>
Joe Tsai <joetsai@digital-static.net>
Joel Stemmer <stemmertech@gmail.com>
Johan Brandhorst <johan.brandhorst@gmail.com>
Johan Sageryd <j@1616.se>
John Asmuth <jasmuth@gmail.com>
John C Barstow <jbowtie@amathaine.com>
@@ -474,12 +441,10 @@ Jonathan Boulle <jonathanboulle@gmail.com>
Jonathan Gold <jgold.bg@gmail.com>
Jonathan Mark <jhmark@xenops.com>
Jonathan Rudenberg <jonathan@titanous.com>
Jonathan Stacks <jonstacks13@gmail.com>
Jonathan Wills <runningwild@gmail.com>
Jongmin Kim <atomaths@gmail.com>
Joonas Kuorilehto <joneskoo@derbian.fi>
Joop Kiefte <ikojba@gmail.com> <joop@kiefte.net>
Jordan Krage <jmank88@gmail.com>
Jordan Lewis <jordanthelewis@gmail.com>
Jose Luis Vázquez González <josvazg@gmail.com>
Joseph Holsten <joseph@josephholsten.com>
@@ -488,9 +453,7 @@ Josh Chorlton <jchorlton@gmail.com>
Josh Goebel <dreamer3@gmail.com>
Josh Holland <jrh@joshh.co.uk>
Joshua Chase <jcjoshuachase@gmail.com>
Josselin Costanzi <josselin@costanzi.fr>
Jostein Stuhaug <js@solidsystem.no>
Joyent, Inc.
JT Olds <jtolds@xnet5.com>
Jukka-Pekka Kekkonen <karatepekka@gmail.com>
Julian Kornberger <jk+github@digineo.de>
@@ -500,16 +463,13 @@ Justin Nuß <nuss.justin@gmail.com>
Justyn Temme <justyntemme@gmail.com>
Kai Backman <kaib@golang.org>
Kale Blankenship <kale@lemnisys.com>
Kamil Chmielewski <kamil.chm@gmail.com>
Kamil Kisiel <kamil@kamilkisiel.net> <kamil.kisiel@gmail.com>
Kang Hu <hukangustc@gmail.com>
Karoly Negyesi <chx1975@gmail.com>
Kato Kazuyoshi <kato.kazuyoshi@gmail.com>
Katrina Owen <katrina.owen@gmail.com>
Kaviraj Kanagaraj <kavirajkanagaraj@gmail.com>
Keegan Carruthers-Smith <keegan.csmith@gmail.com>
Kei Son <hey.calmdown@gmail.com>
Keiji Yoshida <keijiyoshida.mail@gmail.com>
Keith Ball <inflatablewoman@gmail.com>
Keith Rarick <kr@xph.us>
Kelsey Hightower <kelsey.hightower@gmail.com>
@@ -525,31 +485,23 @@ Kevin Burke <kev@inburke.com>
Kevin Kirsche <kev.kirsche@gmail.com>
Kevin Vu <kevin.m.vu@gmail.com>
Klaus Post <klauspost@gmail.com>
Koichi Shiraishi <zchee.io@gmail.com>
Konstantin Shaposhnikov <k.shaposhnikov@gmail.com>
KPCompass, Inc.
Kris Nova <kris@nivenly.com>
Kristopher Watts <traetox@gmail.com>
Kun Li <likunarmstrong@gmail.com>
Kyle Consalus <consalus@gmail.com>
Kyle Isom <kyle@gokyle.net>
Kyle Lemons <kyle@kylelemons.net>
Kyrylo Silin <silin@kyrylo.org>
L Campbell <unpantsu@gmail.com>
Lai Jiangshan <eag0628@gmail.com>
Lars Jeppesen <jeppesen.lars@gmail.com>
Lars Wiegman <lars@namsral.com>
Larz Conwell <larzconwell@gmail.com>
Laurie Clark-Michalek <laurie@qubit.com>
LE Manh Cuong <cuong.manhle.vn@gmail.com>
Lee Hinman <hinman@gmail.com>
Lee Packham <lpackham@gmail.com>
Lewin Bormann <lewin.bormann@gmail.com>
Liberty Fund Inc
Linaro Limited
Lion Yang <lion@aosc.xyz>
Lloyd Dewolf <foolswisdom@gmail.com>
Lorenzo Masini <rugginoso@develer.com>
Lorenzo Stoakes <lstoakes@gmail.com>
Luan Santos <cfcluan@gmail.com>
Luca Greco <luca.greco@alcacoop.it>
@@ -566,10 +518,8 @@ Manu S Ajith <neo@codingarena.in>
Manuel Mendez <mmendez534@gmail.com>
Marc Weistroff <marc@weistroff.net>
Marcel Edmund Franke <marcel.edmund.franke@gmail.com>
Marcelo E. Magallon <marcelo.magallon@gmail.com>
Marco Hennings <marco.hennings@freiheit.com>
Marin Bašić <marin.basic02@gmail.com>
Mark Adams <mark@markadams.me>
Mark Bucciarelli <mkbucc@gmail.com>
Mark Severson <miquella@gmail.com>
Mark Theunissen <mark.theunissen@gmail.com>
@@ -582,29 +532,23 @@ Markus Zimmermann <zimmski@gmail.com>
Martin Bertschler <mbertschler@gmail.com>
Martin Garton <garton@gmail.com>
Martin Hamrle <martin.hamrle@gmail.com>
Martin Lindhe <martin.j.lindhe@gmail.com>
Martin Möhrmann <martisch@uos.de>
Martin Neubauer <m.ne@gmx.net>
Martin Olsson <martin@minimum.se>
Marvin Stenger <marvin.stenger94@gmail.com>
Marwan Sulaiman <marwan.sulaiman@work.co>
Máté Gulyás <mgulyas86@gmail.com>
Mateusz Czapliński <czapkofan@gmail.com>
Mathias Beke <git@denbeke.be>
Mathias Leppich <mleppich@muhqu.de>
Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
Mats Lidell <mats.lidell@cag.se>
Matt Aimonetti <mattaimonetti@gmail.com>
Matt Blair <me@matthewblair.net>
Matt Bostock <matt@mattbostock.com>
Matt Drollette <matt@drollette.com>
Matt Harden <matt.harden@gmail.com>
Matt Jibson <matt.jibson@gmail.com>
Matt Joiner <anacrolix@gmail.com>
Matt Layher <mdlayher@gmail.com>
Matt Reiferson <mreiferson@gmail.com>
Matt Robenolt <matt@ydekproductions.com>
Matt Strong <mstrong1341@gmail.com>
Matt T. Proud <matt.proud@gmail.com>
Matt Williams <gh@mattyw.net>
Matthew Brennan <matty.brennan@gmail.com>
@@ -652,7 +596,6 @@ Mikhail Panchenko <m@mihasya.com>
Miki Tebeka <miki.tebeka@gmail.com>
Mikio Hara <mikioh.mikioh@gmail.com>
Mikkel Krautz <mikkel@krautz.dk>
Milutin Jovanović <jovanovic.milutin@gmail.com>
Miquel Sabaté Solà <mikisabate@gmail.com>
Miroslav Genov <mgenov@gmail.com>
Mohit Agarwal <mohit@sdf.org>
@@ -662,11 +605,8 @@ Moov Corporation
Moriyoshi Koizumi <mozo@mozo.jp>
Morten Siebuhr <sbhr@sbhr.dk>
Môshe van der Sterre <moshevds@gmail.com>
Mostyn Bramley-Moore <mostyn@antipode.se>
Muhammed Uluyol <uluyol0@gmail.com>
Mura Li <mura_li@castech.com.tw>
Nan Deng <monnand@gmail.com>
Nathan Caza <mastercactapus@gmail.com>
Nathan John Youngman <nj@nathany.com>
Nathan Otterness <otternes@cs.unc.edu>
Nathan P Finch <nate.finch@gmail.com>
@@ -675,18 +615,15 @@ Nathan Youngman <git@nathany.com>
Neelesh Chandola <neelesh.c98@gmail.com>
Netflix, Inc.
Nevins Bartolomeo <nevins.bartolomeo@gmail.com>
Nexedi
ngmoco, LLC
Niall Sheridan <nsheridan@gmail.com>
Nic Day <nic.day@me.com>
Nicholas Katsaros <nick@nickkatsaros.com>
Nicholas Maniscalco <nicholas@maniscalco.com>
Nicholas Presta <nick@nickpresta.ca> <nick1presta@gmail.com>
Nicholas Sullivan <nicholas.sullivan@gmail.com>
Nicholas Waples <nwaples@gmail.com>
Nick Craig-Wood <nick@craig-wood.com> <nickcw@gmail.com>
Nick Leli <nicholasleli@gmail.com>
Nick Miyake <nmiyake@users.noreply.github.com>
Nick Patavalis <nick.patavalis@gmail.com>
Nick Petroni <npetroni@cs.umd.edu>
Nicolas Kaiser <nikai@nikai.net>
@@ -695,7 +632,6 @@ Nicolas S. Dade <nic.dade@gmail.com>
Niels Widger <niels.widger@gmail.com>
Nigel Kerr <nigel.kerr@gmail.com>
Nik Nyby <nnyby@columbia.edu>
Niklas Schnelle <niklas.schnelle@gmail.com>
Niko Dziemba <niko@dziemba.com>
Nikolay Turpitko <nikolay@turpitko.com>
Noah Campbell <noahcampbell@gmail.com>
@@ -724,11 +660,9 @@ Patrick Higgins <patrick.allen.higgins@gmail.com>
Patrick Lee <pattyshack101@gmail.com>
Patrick Mézard <patrick@mezard.eu>
Patrick Mylund Nielsen <patrick@patrickmn.com>
Patrick Pelletier <pp.pelletier@gmail.com>
Patrick Smith <pat42smith@gmail.com>
Paul A Querna <paul.querna@gmail.com>
Paul Hammond <paul@paulhammond.org>
Paul Jolly <paul@myitcv.org.uk>
Paul Lalonde <paul.a.lalonde@gmail.com>
Paul Meyer <paul.meyer@microsoft.com>
Paul Rosania <paul.rosania@gmail.com>
@@ -747,7 +681,6 @@ Peter Froehlich <peter.hans.froehlich@gmail.com>
Peter Kleiweg <pkleiweg@xs4all.nl>
Peter Moody <pmoody@uber.com>
Peter Mundy <go.peter.90@gmail.com>
Peter Nguyen <peter@mictis.com>
Péter Surányi <speter.go1@gmail.com>
Péter Szilágyi <peterke@gmail.com>
Peter Waldschmidt <peter@waldschmidt.com>
@@ -761,7 +694,6 @@ Pierre Roullon <pierre.roullon@gmail.com>
Pieter Droogendijk <pieter@binky.org.uk>
Pietro Gagliardi <pietro10@mac.com>
Prashant Varanasi <prashant@prashantv.com>
Pravendra Singh <hackpravj@gmail.com>
Preetam Jinka <pj@preet.am>
Quan Tran <qeed.quan@gmail.com>
Quan Yong Zhai <qyzhai@gmail.com>
@@ -771,14 +703,11 @@ RackTop Systems Inc.
Radu Berinde <radu@cockroachlabs.com>
Rafal Jeczalik <rjeczalik@gmail.com>
Raif S. Naffah <go@naffah-raif.name>
RainTank
Rajat Goel <rajat.goel2010@gmail.com>
Ralph Corderoy <ralph@inputplus.co.uk>
Raphael Geronimi <raphael.geronimi@gmail.com>
Raymond Kazlauskas <raima220@gmail.com>
Red Hat, Inc.
Reinaldo de Souza Jr <juniorz@gmail.com>
Remi Gillig <remigillig@gmail.com>
Rémy Oudompheng <oudomphe@phare.normalesup.org>
Ricardo Padilha <ricardospadilha@gmail.com>
Richard Barnes <rlb@ipv.sx>
@@ -815,7 +744,6 @@ Ryan Slade <ryanslade@gmail.com>
Ryuzo Yamamoto <ryuzo.yamamoto@gmail.com>
S.Çağlar Onur <caglar@10ur.org>
Salmān Aljammāz <s@0x65.net>
Sam Boyer <tech@samboyer.org>
Sam Hug <samuel.b.hug@gmail.com>
Sam Whited <sam@samwhited.com>
Samuele Pedroni <pedronis@lucediurna.net>
@@ -839,7 +767,6 @@ Shaozhen Ding <dsz0111@gmail.com>
Shawn Smith <shawn.p.smith@gmail.com>
Shenghou Ma <minux.ma@gmail.com>
Shinji Tanaka <shinji.tanaka@gmail.com>
Shintaro Kaneko <kaneshin0120@gmail.com>
Shivakumar GN <shivakumar.gn@gmail.com>
Silvan Jegen <s.jegen@gmail.com>
Simon Jefford <simon.jefford@gmail.com>
@@ -883,7 +810,6 @@ Terrel Shumway <gopher@shumway.us>
Tetsuo Kiso <tetsuokiso9@gmail.com>
Thiago Fransosi Farina <thiago.farina@gmail.com>
Thomas Alan Copeland <talan.copeland@gmail.com>
Thomas Bonfort <thomas.bonfort@gmail.com>
Thomas de Zeeuw <thomasdezeeuw@gmail.com>
Thomas Desrosiers <thomasdesr@gmail.com>
Thomas Kappler <tkappler@gmail.com>
@@ -903,11 +829,9 @@ Tom Linford <tomlinford@gmail.com>
Tommy Schaefer <tommy.schaefer@teecom.com>
Tor Andersson <tor.andersson@gmail.com>
Tormod Erevik Lea <tormodlea@gmail.com>
Toshiki Shima <hayabusa1419@gmail.com>
Totoro W <tw19881113@gmail.com>
Travis Cline <travis.cline@gmail.com>
Trey Lawrence <lawrence.trey@gmail.com>
Trey Roessig <trey.roessig@gmail.com>
Trey Tacon <ttacon@gmail.com>
Tristan Colgate <tcolgate@gmail.com>
Tristan Ooohry <ooohry@gmail.com>
@@ -933,19 +857,14 @@ Vladimir Mihailenco <vladimir.webdev@gmail.com>
Vladimir Nikishenko <vova616@gmail.com>
Vladimir Stefanovic <vladimir.stefanovic@imgtec.com>
Volker Dobler <dr.volker.dobler@gmail.com>
Wade Simmons <wade@wades.im>
Weaveworks
Wei Guangjing <vcc.163@gmail.com>
Weichao Tang <tevic.tt@gmail.com>
Will Storey <will@summercat.com>
Willem van der Schyff <willemvds@gmail.com>
William Josephson <wjosephson@gmail.com>
William Orr <will@worrbase.com> <ay1244@gmail.com>
Wisdom Omuya <deafgoat@gmail.com>
Wu Yunzhou <yunzhouwu@gmail.com>
Xia Bin <snyh@snyh.org>
Xing Xing <mikespook@gmail.com>
Xu Fei <badgangkiller@gmail.com>
Xudong Zhang <felixmelon@gmail.com>
Xuyang Kang <xuyangkang@gmail.com>
Yahoo Inc.
@@ -963,14 +882,9 @@ Yusuke Kagiwada <block.rxckin.beats@gmail.com>
Yuusei Kuwana <kuwana@kumama.org>
Yuval Pavel Zholkover <paulzhol@gmail.com>
Zac Bergquist <zbergquist99@gmail.com>
Zach Bintliff <zbintliff@gmail.com>
Zak <zrjknill@gmail.com>
Zellyn Hunter <zellyn@gmail.com>
Zemanta d.o.o.
Zev Goldstein <zev.goldstein@gmail.com>
Ziad Hatahet <hatahet@gmail.com>
Zorion Arrizabalaga <zorionk@gmail.com>
Максим Федосеев <max.faceless.frei@gmail.com>
Фахриддин Балтаев <faxriddinjon@gmail.com>
张嵩 <zs349596@gmail.com>
申习之 <bronze1man@gmail.com>

View File

@@ -4,18 +4,15 @@ Go is an open source project.
It is the work of hundreds of contributors. We appreciate your help!
## Before filing an issue
If you are unsure whether you have found a bug, please consider asking in the [golang-nuts mailing
list](https://groups.google.com/forum/#!forum/golang-nuts) or [other forums](https://golang.org/help/) first. If
the behavior you are seeing is confirmed as a bug or issue, it can easily be re-raised in the issue tracker.
## Filing issues
Sensitive security-related issues should be reported to [security@golang.org](mailto:security@golang.org).
See the [security policy](https://golang.org/security) for details.
General questions should go to the
[golang-nuts mailing list](https://groups.google.com/group/golang-nuts) or
[other forum](https://golang.org/wiki/Questions) instead of the issue tracker.
The gophers there will answer or ask you to file an issue if you've tripped over a bug.
Otherwise, when filing an issue, make sure to answer these five questions:
When filing an issue, make sure to answer these five questions:
1. What version of Go are you using (`go version`)?
2. What operating system and processor architecture are you using?
@@ -25,9 +22,12 @@ Otherwise, when filing an issue, make sure to answer these five questions:
For change proposals, see [Proposing Changes To Go](https://github.com/golang/proposal/).
Sensitive security-related issues should be reported to [security@golang.org](mailto:security@golang.org).
## Contributing code
Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html) before sending patches.
Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html)
before sending patches.
**We do not accept GitHub pull requests**
(we use [an instance](https://go-review.googlesource.com/) of the

View File

@@ -40,18 +40,15 @@ Aaron Torres <tcboox@gmail.com>
Aaron Zinman <aaron@azinman.com>
Abe Haskins <abeisgreat@abeisgreat.com>
Abhinav Gupta <abhinav.g90@gmail.com>
Adam Bender <abender@google.com>
Adam Langley <agl@golang.org>
Adrian Nos <nos.adrian@gmail.com>
Adrian O'Grady <elpollouk@gmail.com>
Adrien Bustany <adrien-xx-google@bustany.org>
Aécio Júnior <aeciodantasjunior@gmail.com>
Ahmed Waheed Moanes <oneofone@gmail.com>
Ahmet Alp Balkan <ahmetb@google.com>
Ahmy Yulrizka <yulrizka@gmail.com>
Aiden Scandella <ai@uber.com>
Ainar Garipov <gugl.zadolbal@gmail.com>
Aishraj Dahal <aishraj@users.noreply.github.com>
Akihiro Suda <suda.kyoto@gmail.com>
Akshat Kumar <seed@mail.nanosouffle.net>
Alan Donovan <adonovan@google.com>
@@ -92,7 +89,6 @@ Alexandre Normand <alexandre.normand@gmail.com>
Alexandru Moșoi <brtzsnr@gmail.com>
Alexei Sholik <alcosholik@gmail.com>
Alexey Borzenkov <snaury@gmail.com>
Alexey Neganov <neganovalexey@gmail.com>
Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
Alexis Imperial-Legrand <ail@google.com>
Aliaksandr Valialkin <valyala@gmail.com>
@@ -111,7 +107,6 @@ Andrei Vieru <euvieru@gmail.com>
Andres Erbsen <andreser@google.com>
Andrew Austin <andrewaclt@gmail.com>
Andrew Balholm <andybalholm@gmail.com>
Andrew Benton <andrewmbenton@gmail.com>
Andrew Bonventre <andybons@chromium.org>
Andrew Bursavich <abursavich@gmail.com>
Andrew Ekstedt <andrew.ekstedt@gmail.com>
@@ -170,14 +165,12 @@ Ayanamist Yang <ayanamist@gmail.com>
Aymerick Jéhanne <aymerick@jehanne.org>
Baiju Muthukadan <baiju.m.mail@gmail.com>
Balazs Lecz <leczb@google.com>
Bartosz Grzybowski <melkorm@gmail.com>
Ben Burkert <ben@benburkert.com>
Ben Eitzen <eitzenb@golang.org>
Ben Fried <ben.fried@gmail.com>
Ben Lubar <ben.lubar@gmail.com>
Ben Lynn <benlynn@gmail.com>
Ben Olive <sionide21@gmail.com>
Ben Shi <powerman1st@163.com>
Benjamin Black <b@b3k.us>
Benjamin Prosnitz <bprosnitz@google.com>
Benjamin Wester <bwester@squareup.com>
@@ -201,7 +194,6 @@ Brad Garcia <bgarcia@golang.org>
Braden Bassingthwaite <bbassingthwaite@vendasta.com>
Brady Catherman <brady@gmail.com>
Brady Sullivan <brady@bsull.com>
Brandon Bennett <bbennett@fb.com>
Brandon Gilmore <varz@google.com>
Brendan Daniel Tracey <tracey.brendan@gmail.com>
Brendan O'Dea <bod@golang.org>
@@ -213,27 +205,21 @@ Brian Kennedy <btkennedy@gmail.com>
Brian Ketelsen <bketelsen@gmail.com>
Brian Slesinsky <skybrian@google.com>
Brian Smith <ohohvi@gmail.com>
Brian Starke <brian.starke@gmail.com>
Bryan Alexander <Kozical@msn.com>
Bryan C. Mills <bcmills@google.com>
Bryan Chan <bryan.chan@ca.ibm.com>
Bryan Ford <brynosaurus@gmail.com>
Bulat Gaifullin <gaifullinbf@gmail.com>
Caine Tighe <arctanofyourface@gmail.com>
Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Caleb Spare <cespare@gmail.com>
Carl Chatfield <carlchatfield@gmail.com>
Carl Henrik Lunde <chlunde@ifi.uio.no>
Carl Jackson <carl@stripe.com>
Carl Johnson <me@carlmjohnson.net>
Carl Mastrangelo <notcarl@google.com>
Carl Shapiro <cshapiro@google.com> <cshapiro@golang.org>
Carlisia Campos <carlisia@grokkingtech.io>
Carlo Alberto Ferraris <cafxx@strayorange.com>
Carlos Castillo <cookieo9@gmail.com>
Carlos Cirello <uldericofilho@gmail.com>
Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Carolyn Van Slyck <me@carolynvanslyck.com>
Cary Hull <chull@google.com>
Case Nelson <case.nelson@gmail.com>
Casey Marshall <casey.marshall@gmail.com>
@@ -246,8 +232,6 @@ Charles L. Dorian <cldorian@gmail.com>
Charles Lee <zombie.fml@gmail.com>
Charles Weill <weill@google.com>
Cherry Zhang <cherryyz@google.com>
Chew Choon Keat <choonkeat@gmail.com>
Chris Biscardi <chris@christopherbiscardi.com>
Chris Broadfoot <cbro@golang.org>
Chris Dollin <ehog.hedge@gmail.com>
Chris Farmiloe <chrisfarms@gmail.com>
@@ -288,7 +272,6 @@ Cristian Staretu <unclejacksons@gmail.com>
Cuihtlauac ALVARADO <cuihtlauac.alvarado@orange.com>
Cyrill Schumacher <cyrill@schumacher.fm>
Damian Gryski <dgryski@gmail.com>
Damien Lespiau <damien.lespiau@gmail.com> <damien.lespiau@intel.com>
Damien Neil <dneil@google.com>
Dan Caddigan <goldcaddy77@gmail.com>
Dan Callahan <dan.callahan@gmail.com>
@@ -336,7 +319,6 @@ David Jakob Fritz <david.jakob.fritz@gmail.com>
David Lazar <lazard@golang.org>
David Leon Gil <coruus@gmail.com>
David McLeish <davemc@google.com>
David NewHamlet <david@newhamlet.com>
David Presotto <presotto@gmail.com>
David R. Jenni <david.r.jenni@gmail.com>
David Sansome <me@davidsansome.com>
@@ -360,7 +342,6 @@ Dhaivat Pandit <dhaivatpandit@gmail.com>
Dhananjay Nakrani <dhananjayn@google.com>
Dhiru Kholia <dhiru.kholia@gmail.com>
Didier Spezia <didier.06@gmail.com>
Dieter Plaetinck <dieter@raintank.io>
Dimitri Tcaciuc <dtcaciuc@gmail.com>
Dirk Gadsden <dirk@esherido.com>
Diwaker Gupta <diwakergupta@gmail.com>
@@ -372,7 +353,6 @@ Dmitriy Vyukov <dvyukov@google.com>
Dmitry Chestnykh <dchest@gmail.com>
Dmitry Savintsev <dsavints@gmail.com>
Dmitry Yakunin <nonamezeil@gmail.com>
Dominic Green <dominicgreen1@gmail.com>
Dominik Honnef <dominik.honnef@gmail.com>
Dominik Vogt <vogt@linux.vnet.ibm.com>
Donald Huang <don.hcd@gmail.com>
@@ -390,7 +370,6 @@ Eden Li <eden.li@gmail.com>
Edward Muller <edwardam@interlix.com>
Egon Elbre <egonelbre@gmail.com>
Ehren Kret <ehren.kret@gmail.com>
Eitan Adler <lists@eitanadler.com>
Eivind Uggedal <eivind@uggedal.com>
Elias Naur <elias.naur@gmail.com>
Elliot Morrison-Reed <elliotmr@gmail.com>
@@ -420,22 +399,17 @@ Evan Kroske <evankroske@google.com>
Evan Martin <evan.martin@gmail.com>
Evan Phoenix <evan@phx.io>
Evan Shaw <chickencha@gmail.com>
Evgeniy Polyakov <zbr@ioremap.net>
Ewan Chou <coocood@gmail.com>
Ewan Valentine <ewan.valentine89@gmail.com>
Fabian Wickborn <fabian@wickborn.net>
Fabrizio Milo <mistobaan@gmail.com>
Faiyaz Ahmed <ahmedf@vmware.com>
Fan Hongjian <fan.howard@gmail.com>
Fangming Fang <fangming.fang@arm.com>
Fatih Arslan <fatih@arslan.io>
Fazlul Shahriar <fshahriar@gmail.com>
Federico Simoncelli <fsimonce@redhat.com>
Fedor Indutny <fedor@indutny.com>
Felipe Oliveira <felipeweb.programador@gmail.com>
Felix Geisendörfer <haimuiba@gmail.com>
Filip Gruszczyński <gruszczy@gmail.com>
Filippo Valsorda <filippo@cloudflare.com> <hi@filippo.io>
Filippo Valsorda <hi@filippo.io>
Firmansyah Adiputra <frm.adiputra@gmail.com>
Florian Uekermann <florian@uekermann-online.de> <f1@uekermann-online.de>
Florian Weimer <fw@deneb.enyo.de>
@@ -460,10 +434,8 @@ Gary Elliott <garyelliott@google.com>
Gaurish Sharma <contact@gaurishsharma.com>
Gautham Thambidorai <gautham.dorai@gmail.com>
Geert-Johan Riemer <gjr19912@gmail.com>
Gengliang Wang <ltnwgl@gmail.com>
Geoffroy Lorieux <lorieux.g@gmail.com>
Georg Reinke <guelfey@gmail.com>
George Gkirtsou <ggirtsou@gmail.com>
George Shammas <george@shamm.as> <georgyo@gmail.com>
Gerasimos Dimitriadis <gedimitr@gmail.com>
Gideon Jan-Wessel Redelinghuys <gjredelinghuys@gmail.com>
@@ -477,7 +449,6 @@ Gordon Klaus <gordon.klaus@gmail.com>
Graham King <graham4king@gmail.com>
Graham Miller <graham.miller@gmail.com>
Greg Ward <greg@gerg.ca>
Gregory Man <man.gregory@gmail.com>
Guillaume J. Charmes <guillaume@charmes.net>
Guobiao Mei <meiguobiao@gmail.com>
Gustav Paul <gustav.paul@gmail.com>
@@ -494,7 +465,6 @@ Hariharan Srinath <srinathh@gmail.com>
Harley Laue <losinggeneration@gmail.com>
Harry Moreno <morenoh149@gmail.com>
Harshavardhana <hrshvardhana@gmail.com>
Hauke Löffler <hloeffler@users.noreply.github.com>
Håvard Haugen <havard.haugen@gmail.com>
Hector Chu <hectorchu@gmail.com>
Hector Martin Cantero <hector@marcansoft.com>
@@ -502,21 +472,17 @@ Henning Schmiedehausen <henning@schmiedehausen.org>
Henrik Edwards <henrik.edwards@gmail.com>
Henrik Hodne <henrik@hodne.io>
Herbert Georg Fischer <herbert.fischer@gmail.com>
Heschi Kreinick <heschi@google.com>
Hironao OTSUBO <motemen@gmail.com>
Hiroshi Ioka <hirochachacha@gmail.com>
Hitoshi Mitake <mitake.hitoshi@gmail.com>
Holden Huang <ttyh061@gmail.com>
Hong Ruiqi <hongruiqi@gmail.com>
Hongfei Tan <feilengcui008@gmail.com>
Hossein Sheikh Attar <hattar@google.com>
Hsin-Ho Yeh <yhh92u@gmail.com>
Hu Keping <hukeping@huawei.com>
Hugues Bruant <hugues.bruant@gmail.com>
Hyang-Ah Hana Kim <hakim@google.com> <hyangah@gmail.com>
Ian Gudger <ian@loosescre.ws>
Ian Lance Taylor <iant@golang.org>
Ibrahim AshShohail <ibra.sho@gmail.com>
Icarus Sparry <golang@icarus.freeuk.com>
Idora Shinatose <idora.shinatose@gmail.com>
Igor Bernstein <igorbernstein@google.com>
@@ -547,25 +513,22 @@ James David Chalfant <james.chalfant@gmail.com>
James Fysh <james.fysh@gmail.com>
James Gray <james@james4k.com>
James Meneghello <rawrz0r@gmail.com>
James Neve <jamesoneve@gmail.com>
James P. Cooper <jamespcooper@gmail.com>
James Robinson <jamesr@google.com> <jamesr.gatech@gmail.com>
James Schofield <james@shoeboxapp.com>
James Smith <jrs1995@icloud.com>
James Sweet <james.sweet88@googlemail.com>
James Toy <nil@opensesame.st>
James Tucker <raggi@google.com>
James Whitehead <jnwhiteh@gmail.com>
Jamie Beverly <jamie.r.beverly@gmail.com>
Jamie Gennis <jgennis@google.com> <jgennis@gmail.com>
Jamie Stackhouse <contin673@gmail.com>
Jamie Turner <jamwt@dropbox.com>
Jamie Wilkinson <jaq@spacepants.org>
Jamil Djadala <djadala@gmail.com>
Jan Berktold <jan@berktold.co>
Jan H. Hosang <jan.hosang@gmail.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
Jan Mercl <0xjnml@gmail.com> <befelemepeseveze@gmail.com>
Jan Mercl <0xjnml@gmail.com>
Jan Mercl <befelemepeseveze@gmail.com>
Jan Newmarch <jan.newmarch@gmail.com>
Jan Ziak <0xe2.0x9a.0x9b@gmail.com>
Jani Monoses <jani.monoses@ubuntu.com> <jani.monoses@gmail.com>
@@ -582,7 +545,6 @@ Jean-Nicolas Moal <jn.moal@gmail.com>
Jed Denlea <jed@fastly.com>
Jeff Craig <jeffcraig@google.com>
Jeff Hodges <jeff@somethingsimilar.com>
Jeff Johnson <jrjohnson@google.com>
Jeff R. Allen <jra@nella.org> <jeff.allen@gmail.com>
Jeff Sickel <jas@corpus-callosum.com>
Jeff Wendling <jeff@spacemonkey.com>
@@ -607,14 +569,11 @@ Joe Farrell <joe2farrell@gmail.com>
Joe Harrison <joehazzers@gmail.com>
Joe Henke <joed.henke@gmail.com>
Joe Poirier <jdpoirier@gmail.com>
Joe Richey joerichey@google.com <joerichey@google.com>
Joe Shaw <joe@joeshaw.org>
Joe Sylve <joe.sylve@gmail.com>
Joe Tsai <joetsai@digital-static.net>
Joel Sing <jsing@google.com>
Joël Stemmer <jstemmer@google.com>
Joel Stemmer <stemmertech@gmail.com>
Johan Brandhorst <johan.brandhorst@gmail.com>
Johan Euphrosine <proppy@google.com>
Johan Sageryd <j@1616.se>
John Asmuth <jasmuth@gmail.com>
@@ -642,12 +601,10 @@ Jonathan Mark <jhmark@xenops.com> <jhmark000@gmail.com>
Jonathan Nieder <jrn@google.com>
Jonathan Pittman <jmpittman@google.com> <jonathan.mark.pittman@gmail.com>
Jonathan Rudenberg <jonathan@titanous.com>
Jonathan Stacks <jonstacks13@gmail.com>
Jonathan Wills <runningwild@gmail.com>
Jongmin Kim <atomaths@gmail.com>
Joonas Kuorilehto <joneskoo@derbian.fi>
Joop Kiefte <ikojba@gmail.com> <joop@kiefte.net>
Jordan Krage <jmank88@gmail.com>
Jordan Lewis <jordanthelewis@gmail.com>
Jos Visser <josv@google.com>
Jose Luis Vázquez González <josvazg@gmail.com>
@@ -660,7 +617,6 @@ Josh Hoak <jhoak@google.com>
Josh Holland <jrh@joshh.co.uk>
Joshua Boelter <joshua.boelter@intel.com>
Joshua Chase <jcjoshuachase@gmail.com>
Josselin Costanzi <josselin@costanzi.fr>
Jostein Stuhaug <js@solidsystem.no>
JP Sugarbroad <jpsugar@google.com>
JT Olds <jtolds@xnet5.com>
@@ -669,7 +625,6 @@ Julia Hansbrough <flowerhack@google.com>
Julian Kornberger <jk+github@digineo.de>
Julian Phillips <julian@quantumfyre.co.uk>
Julien Schmidt <google@julienschmidt.com>
Julio Montes <julio.montes@intel.com>
Jungho Ahn <jhahn@google.com>
Jure Ham <jure.ham@zemanta.com>
Justin Nuß <nuss.justin@gmail.com>
@@ -677,11 +632,9 @@ Justyn Temme <justyntemme@gmail.com>
Kai Backman <kaib@golang.org>
Kale Blankenship <kale@lemnisys.com>
Kamal Aboul-Hosn <aboulhosn@google.com>
Kamil Chmielewski <kamil.chm@gmail.com>
Kamil Kisiel <kamil@kamilkisiel.net> <kamil.kisiel@gmail.com>
Kang Hu <hukangustc@gmail.com>
Karan Dhiman <karandhi@ca.ibm.com>
Karoly Negyesi <chx1975@gmail.com>
Kato Kazuyoshi <kato.kazuyoshi@gmail.com>
Katrina Owen <katrina.owen@gmail.com>
Kaviraj Kanagaraj <kavirajkanagaraj@gmail.com>
@@ -689,7 +642,6 @@ Kay Zhu <kayzhu@google.com>
KB Sriram <kbsriram@google.com>
Keegan Carruthers-Smith <keegan.csmith@gmail.com>
Kei Son <hey.calmdown@gmail.com>
Keiji Yoshida <keijiyoshida.mail@gmail.com>
Keith Ball <inflatablewoman@gmail.com>
Keith Randall <khr@golang.org>
Keith Rarick <kr@xph.us>
@@ -709,38 +661,28 @@ Kevin Klues <klueska@gmail.com> <klueska@google.com>
Kevin Malachowski <chowski@google.com>
Kevin Vu <kevin.m.vu@gmail.com>
Kim Shrier <kshrier@racktopsystems.com>
Kirill Smelkov <kirr@nexedi.com>
Kirklin McDonald <kirklin.mcdonald@gmail.com>
Klaus Post <klauspost@gmail.com>
Koichi Shiraishi <zchee.io@gmail.com>
Konstantin Shaposhnikov <k.shaposhnikov@gmail.com>
Kris Nova <kris@nivenly.com>
Kris Rousey <krousey@google.com>
Kristopher Watts <traetox@gmail.com>
Kun Li <likunarmstrong@gmail.com>
Kyle Consalus <consalus@gmail.com>
Kyle Isom <kyle@gokyle.net>
Kyle Lemons <kyle@kylelemons.net> <kevlar@google.com>
Kyrylo Silin <silin@kyrylo.org>
L Campbell <unpantsu@gmail.com>
Lai Jiangshan <eag0628@gmail.com>
Larry Hosken <lahosken@golang.org>
Lars Jeppesen <jeppesen.lars@gmail.com>
Lars Wiegman <lars@namsral.com>
Larz Conwell <larzconwell@gmail.com>
Laurie Clark-Michalek <laurie@qubit.com>
LE Manh Cuong <cuong.manhle.vn@gmail.com>
Lee Hinman <hinman@gmail.com>
Lee Packham <lpackham@gmail.com>
Lewin Bormann <lewin.bormann@gmail.com>
Lion Yang <lion@aosc.xyz>
Lloyd Dewolf <foolswisdom@gmail.com>
Lorenzo Masini <rugginoso@develer.com>
Lorenzo Stoakes <lstoakes@gmail.com>
Louis Kruger <louisk@google.com>
Luan Santos <cfcluan@gmail.com>
Luca Greco <luca.greco@alcacoop.it>
Lucas Clemente <lclemente@google.com>
Lucien Stuker <lucien.stuker@gmail.com>
Lucio De Re <lucio.dere@gmail.com>
Luigi Riefolo <luigi.riefolo@gmail.com>
@@ -761,15 +703,11 @@ Marc Weistroff <marc@weistroff.net>
Marc-Antoine Ruel <maruel@chromium.org>
Marcel Edmund Franke <marcel.edmund.franke@gmail.com>
Marcel van Lohuizen <mpvl@golang.org>
Marcelo E. Magallon <marcelo.magallon@gmail.com>
Marco Hennings <marco.hennings@freiheit.com>
Marga Manterola <marga@google.com>
Marin Bašić <marin.basic02@gmail.com>
Marius Nuennerich <mnu@google.com>
Mark Adams <mark@markadams.me>
Mark Bucciarelli <mkbucc@gmail.com>
Mark Harrison <marhar@google.com>
Mark Ryan <mark.d.ryan@intel.com>
Mark Severson <miquella@gmail.com>
Mark Theunissen <mark.theunissen@gmail.com>
Mark Zavislak <zavislak@google.com>
@@ -783,31 +721,25 @@ Martin Bertschler <mbertschler@gmail.com>
Martin Garton <garton@gmail.com>
Martin Hamrle <martin.hamrle@gmail.com>
Martin Kreichgauer <martinkr@google.com>
Martin Lindhe <martin.j.lindhe@gmail.com>
Martin Möhrmann <moehrmann@google.com> <martisch@uos.de>
Martin Neubauer <m.ne@gmx.net>
Martin Olsson <martin@minimum.se>
Marvin Stenger <marvin.stenger94@gmail.com>
Marwan Sulaiman <marwan.sulaiman@work.co>
Máté Gulyás <mgulyas86@gmail.com>
Mateusz Czapliński <czapkofan@gmail.com>
Mathias Beke <git@denbeke.be>
Mathias Leppich <mleppich@muhqu.de>
Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
Mats Lidell <mats.lidell@cag.se> <mats.lidell@gmail.com>
Matt Aimonetti <mattaimonetti@gmail.com>
Matt Blair <me@matthewblair.net>
Matt Bostock <matt@mattbostock.com>
Matt Brown <mdbrown@google.com>
Matt Drollette <matt@drollette.com>
Matt Harden <matt.harden@gmail.com>
Matt Jibson <matt.jibson@gmail.com>
Matt Joiner <anacrolix@gmail.com>
Matt Jones <mrjones@google.com>
Matt Layher <mdlayher@gmail.com>
Matt Reiferson <mreiferson@gmail.com>
Matt Robenolt <matt@ydekproductions.com>
Matt Strong <mstrong1341@gmail.com>
Matt T. Proud <matt.proud@gmail.com>
Matt Williams <gh@mattyw.net> <mattyjwilliams@gmail.com>
Matthew Brennan <matty.brennan@gmail.com>
@@ -869,28 +801,22 @@ Mike Rosset <mike.rosset@gmail.com>
Mike Samuel <mikesamuel@gmail.com>
Mike Solomon <msolo@gmail.com>
Mike Strosaker <strosake@us.ibm.com>
Mike Wiacek <mjwiacek@google.com>
Mikhail Gusarov <dottedmag@dottedmag.net>
Mikhail Panchenko <m@mihasya.com>
Miki Tebeka <miki.tebeka@gmail.com>
Mikio Hara <mikioh.mikioh@gmail.com>
Mikkel Krautz <mikkel@krautz.dk> <krautz@gmail.com>
Milutin Jovanović <jovanovic.milutin@gmail.com>
Miquel Sabaté Solà <mikisabate@gmail.com>
Miroslav Genov <mgenov@gmail.com>
Mohit Agarwal <mohit@sdf.org>
Momchil Velikov <momchil.velikov@gmail.com>
Monis Khan <mkhan@redhat.com>
Monty Taylor <mordred@inaugust.com>
Moriyoshi Koizumi <mozo@mozo.jp>
Morten Siebuhr <sbhr@sbhr.dk>
Môshe van der Sterre <moshevds@gmail.com>
Mostyn Bramley-Moore <mostyn@antipode.se>
Mrunal Patel <mrunalp@gmail.com>
Muhammed Uluyol <uluyol0@gmail.com>
Mura Li <mura_li@castech.com.tw>
Nan Deng <monnand@gmail.com>
Nathan Caza <mastercactapus@gmail.com>
Nathan John Youngman <nj@nathany.com>
Nathan Otterness <otternes@cs.unc.edu>
Nathan P Finch <nate.finch@gmail.com>
@@ -902,16 +828,13 @@ Nevins Bartolomeo <nevins.bartolomeo@gmail.com>
Niall Sheridan <nsheridan@gmail.com>
Nic Day <nic.day@me.com>
Nicholas Katsaros <nick@nickkatsaros.com>
Nicholas Maniscalco <nicholas@maniscalco.com>
Nicholas Presta <nick@nickpresta.ca> <nick1presta@gmail.com>
Nicholas Sullivan <nicholas.sullivan@gmail.com>
Nicholas Waples <nwaples@gmail.com>
Nick Cooper <nmvc@google.com>
Nick Craig-Wood <nick@craig-wood.com> <nickcw@gmail.com>
Nick Harper <nharper@google.com>
Nick Kubala <nkubala@google.com>
Nick Leli <nicholasleli@gmail.com>
Nick Miyake <nmiyake@users.noreply.github.com>
Nick Patavalis <nick.patavalis@gmail.com>
Nick Petroni <npetroni@cs.umd.edu>
Nicolas Kaiser <nikai@nikai.net>
@@ -921,7 +844,6 @@ Niels Widger <niels.widger@gmail.com>
Nigel Kerr <nigel.kerr@gmail.com>
Nigel Tao <nigeltao@golang.org>
Nik Nyby <nnyby@columbia.edu>
Niklas Schnelle <niklas.schnelle@gmail.com>
Niko Dziemba <niko@dziemba.com>
Nikolay Turpitko <nikolay@turpitko.com>
Noah Campbell <noahcampbell@gmail.com>
@@ -949,7 +871,6 @@ Patrick Higgins <patrick.allen.higgins@gmail.com>
Patrick Lee <pattyshack101@gmail.com>
Patrick Mézard <patrick@mezard.eu>
Patrick Mylund Nielsen <patrick@patrickmn.com>
Patrick Pelletier <pp.pelletier@gmail.com>
Patrick Riley <pfr@google.com>
Patrick Smith <pat42smith@gmail.com>
Paul A Querna <paul.querna@gmail.com>
@@ -957,7 +878,6 @@ Paul Borman <borman@google.com>
Paul Chang <paulchang@google.com>
Paul Hammond <paul@paulhammond.org>
Paul Hankin <paulhankin@google.com>
Paul Jolly <paul@myitcv.org.uk>
Paul Lalonde <paul.a.lalonde@gmail.com>
Paul Marks <pmarks@google.com>
Paul Meyer <paul.meyer@microsoft.com>
@@ -968,7 +888,6 @@ Paul Smith <paulsmith@pobox.com> <paulsmith@gmail.com>
Paul van Brouwershaven <paul@vanbrouwershaven.com>
Paul Wankadia <junyer@google.com>
Paulo Casaretto <pcasaretto@gmail.com>
Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
Pavel Paulau <pavel.paulau@gmail.com>
Pavel Zinovkin <pavel.zinovkin@gmail.com>
Pawel Knap <pawelknap88@gmail.com>
@@ -984,7 +903,6 @@ Peter Kleiweg <pkleiweg@xs4all.nl>
Peter McKenzie <petermck@google.com>
Peter Moody <pmoody@uber.com>
Peter Mundy <go.peter.90@gmail.com>
Peter Nguyen <peter@mictis.com>
Péter Surányi <speter.go1@gmail.com>
Péter Szabó <pts@google.com>
Péter Szilágyi <peterke@gmail.com>
@@ -1003,7 +921,6 @@ Pieter Droogendijk <pieter@binky.org.uk>
Pietro Gagliardi <pietro10@mac.com>
Prasanna Swaminathan <prasanna@mediamath.com>
Prashant Varanasi <prashant@prashantv.com>
Pravendra Singh <hackpravj@gmail.com>
Preetam Jinka <pj@preet.am>
Quan Tran <qeed.quan@gmail.com>
Quan Yong Zhai <qyzhai@gmail.com>
@@ -1021,10 +938,8 @@ Ramesh Dharan <dharan@google.com>
Raph Levien <raph@google.com>
Raphael Geronimi <raphael.geronimi@gmail.com>
Raul Silvera <rsilvera@google.com>
Raymond Kazlauskas <raima220@gmail.com>
Rebecca Stambler <rstambler@golang.org>
Reinaldo de Souza Jr <juniorz@gmail.com>
Remi Gillig <remigillig@gmail.com>
Rémy Oudompheng <oudomphe@phare.normalesup.org> <remyoudompheng@gmail.com>
Rhys Hiltner <rhys@justin.tv>
Ricardo Padilha <ricardospadilha@gmail.com>
@@ -1075,7 +990,6 @@ Ryuzo Yamamoto <ryuzo.yamamoto@gmail.com>
S.Çağlar Onur <caglar@10ur.org>
Sai Cheemalapati <saicheems@google.com>
Salmān Aljammāz <s@0x65.net>
Sam Boyer <tech@samboyer.org>
Sam Ding <samding@ca.ibm.com>
Sam Hug <samuel.b.hug@gmail.com>
Sam Thorogood <thorogood@google.com> <sam.thorogood@gmail.com>
@@ -1096,8 +1010,6 @@ Scott Mansfield <smansfield@netflix.com>
Scott Schwartz <scotts@golang.org>
Scott Van Woudenberg <scottvw@google.com>
Sean Burford <sburford@google.com>
Sean Chittenden <seanc@joyent.com>
Sean Christopherson <sean.j.christopherson@intel.com>
Sean Dolphin <Sean.Dolphin@kpcompass.com>
Sean Harger <sharger@google.com>
Sean Rees <sean@erifax.org>
@@ -1117,7 +1029,6 @@ Shawn Smith <shawn.p.smith@gmail.com>
Shawn Walker-Salas <shawn.walker@oracle.com>
Shenghou Ma <minux@golang.org> <minux.ma@gmail.com>
Shinji Tanaka <shinji.tanaka@gmail.com>
Shintaro Kaneko <kaneshin0120@gmail.com>
Shivakumar GN <shivakumar.gn@gmail.com>
Shun Fan <sfan@google.com>
Silvan Jegen <s.jegen@gmail.com>
@@ -1157,7 +1068,6 @@ Tad Glines <tad.glines@gmail.com>
Taj Khattra <taj.khattra@gmail.com>
Takashi Matsuo <tmatsuo@google.com>
Takeshi YAMANASHI <9.nashi@gmail.com>
Takuto Ikuta <tikuta@google.com>
Takuya Ueda <uedatakuya@gmail.com>
Tal Shprecher <tshprecher@gmail.com>
Tamir Duberstein <tamird@gmail.com>
@@ -1169,7 +1079,6 @@ Tetsuo Kiso <tetsuokiso9@gmail.com>
Than McIntosh <thanm@google.com>
Thiago Fransosi Farina <thiago.farina@gmail.com> <tfarina@chromium.org>
Thomas Alan Copeland <talan.copeland@gmail.com>
Thomas Bonfort <thomas.bonfort@gmail.com>
Thomas de Zeeuw <thomasdezeeuw@gmail.com>
Thomas Desrosiers <thomasdesr@gmail.com>
Thomas Habets <habets@google.com>
@@ -1198,12 +1107,10 @@ Tom Wilkie <tom@weave.works>
Tommy Schaefer <tommy.schaefer@teecom.com>
Tor Andersson <tor.andersson@gmail.com>
Tormod Erevik Lea <tormodlea@gmail.com>
Toshiki Shima <hayabusa1419@gmail.com>
Totoro W <tw19881113@gmail.com>
Travis Cline <travis.cline@gmail.com>
Trevor Strohman <trevor.strohman@gmail.com>
Trey Lawrence <lawrence.trey@gmail.com>
Trey Roessig <trey.roessig@gmail.com>
Trey Tacon <ttacon@gmail.com>
Tristan Amini <tamini01@ca.ibm.com>
Tristan Colgate <tcolgate@gmail.com>
@@ -1235,24 +1142,18 @@ Vladimir Nikishenko <vova616@gmail.com>
Vladimir Stefanovic <vladimir.stefanovic@imgtec.com>
Volker Dobler <dr.volker.dobler@gmail.com>
Volodymyr Paprotski <vpaprots@ca.ibm.com>
Wade Simmons <wade@wades.im>
Walter Poupore <wpoupore@google.com>
Wedson Almeida Filho <wedsonaf@google.com>
Wei Guangjing <vcc.163@gmail.com>
Wei Xiao <wei.xiao@arm.com>
Weichao Tang <tevic.tt@gmail.com>
Will Chan <willchan@google.com>
Will Norris <willnorris@google.com>
Will Storey <will@summercat.com>
Willem van der Schyff <willemvds@gmail.com>
William Chan <willchan@chromium.org>
William Josephson <wjosephson@gmail.com>
William Orr <will@worrbase.com> <ay1244@gmail.com>
Wisdom Omuya <deafgoat@gmail.com>
Wu Yunzhou <yunzhouwu@gmail.com>
Xia Bin <snyh@snyh.org>
Xing Xing <mikespook@gmail.com>
Xu Fei <badgangkiller@gmail.com>
Xudong Zhang <felixmelon@gmail.com>
Xuyang Kang <xuyangkang@gmail.com>
Yan Zou <yzou@google.com>
@@ -1274,14 +1175,9 @@ Yuusei Kuwana <kuwana@kumama.org>
Yuval Pavel Zholkover <paulzhol@gmail.com>
Yves Junqueira <yvesj@google.com> <yves.junqueira@gmail.com>
Zac Bergquist <zbergquist99@gmail.com>
Zach Bintliff <zbintliff@gmail.com>
Zak <zrjknill@gmail.com>
Zellyn Hunter <zellyn@squareup.com> <zellyn@gmail.com>
Zev Goldstein <zev.goldstein@gmail.com>
Zhongwei Yao <zhongwei.yao@arm.com>
Ziad Hatahet <hatahet@gmail.com>
Zorion Arrizabalaga <zorionk@gmail.com>
Максим Федосеев <max.faceless.frei@gmail.com>
Фахриддин Балтаев <faxriddinjon@gmail.com>
张嵩 <zs349596@gmail.com>
申习之 <bronze1man@gmail.com>

View File

@@ -4,42 +4,40 @@ Go is an open source programming language that makes it easy to build simple,
reliable, and efficient software.
![Gopher image](doc/gopher/fiveyears.jpg)
*Gopher image by [Renee French][rf], licensed under [Creative Commons 3.0 Attributions license][cc3-by].*
For documentation about how to install and use Go,
visit https://golang.org/ or load doc/install-source.html
in your web browser.
Our canonical Git repository is located at https://go.googlesource.com/go.
There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the
BSD-style license found in the LICENSE file.
### Download and Install
#### Binary Distributions
Official binary distributions are available at https://golang.org/dl/.
After downloading a binary release, visit https://golang.org/doc/install
or load doc/install.html in your web browser for installation
instructions.
#### Install From Source
If a binary distribution is not available for your combination of
operating system and architecture, visit
https://golang.org/doc/install/source or load doc/install-source.html
in your web browser for source installation instructions.
### Contributing
Go is the work of hundreds of contributors. We appreciate your help!
To contribute, please read the contribution guidelines:
https://golang.org/doc/contribute.html
Note that the Go project does not use GitHub pull requests, and that
we use the issue tracker for bug reports and proposals only. See
https://golang.org/wiki/Questions for a list of places to ask
questions about the Go language.
##### Note that we do not accept pull requests and that we use the issue tracker for bug reports and proposals only. Please ask questions on https://forum.golangbridge.org or https://groups.google.com/forum/#!forum/golang-nuts.
[rf]: https://reneefrench.blogspot.com/
[cc3-by]: https://creativecommons.org/licenses/by/3.0/
Unless otherwise noted, the Go source files are distributed
under the BSD-style license found in the LICENSE file.
--
## Binary Distribution Notes
If you have just untarred a binary Go distribution, you need to set
the environment variable $GOROOT to the full path of the go
directory (the one containing this file). You can omit the
variable if you unpack it into /usr/local/go, or if you rebuild
from sources by running all.bash (see doc/install-source.html).
You should also add the Go binary directory $GOROOT/bin
to your shell's path.
For example, if you extracted the tar file into $HOME/go, you might
put the following in your .profile:
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
See https://golang.org/doc/install or doc/install.html for more details.

View File

@@ -1,5 +1,4 @@
pkg encoding/json, method (*RawMessage) MarshalJSON() ([]uint8, error)
pkg math/big, type Word uintptr
pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error)
pkg os (linux-arm), const O_SYNC = 4096
pkg os (linux-arm-cgo), const O_SYNC = 4096

View File

@@ -1,163 +0,0 @@
pkg crypto, const BLAKE2b_256 = 17
pkg crypto, const BLAKE2b_256 Hash
pkg crypto, const BLAKE2b_384 = 18
pkg crypto, const BLAKE2b_384 Hash
pkg crypto, const BLAKE2b_512 = 19
pkg crypto, const BLAKE2b_512 Hash
pkg crypto, const BLAKE2s_256 = 16
pkg crypto, const BLAKE2s_256 Hash
pkg crypto/x509, type Certificate struct, ExcludedDNSDomains []string
pkg database/sql, method (*Conn) BeginTx(context.Context, *TxOptions) (*Tx, error)
pkg database/sql, method (*Conn) Close() error
pkg database/sql, method (*Conn) ExecContext(context.Context, string, ...interface{}) (Result, error)
pkg database/sql, method (*Conn) PingContext(context.Context) error
pkg database/sql, method (*Conn) PrepareContext(context.Context, string) (*Stmt, error)
pkg database/sql, method (*Conn) QueryContext(context.Context, string, ...interface{}) (*Rows, error)
pkg database/sql, method (*Conn) QueryRowContext(context.Context, string, ...interface{}) *Row
pkg database/sql, method (*DB) Conn(context.Context) (*Conn, error)
pkg database/sql, type Conn struct
pkg database/sql, type Out struct
pkg database/sql, type Out struct, Dest interface{}
pkg database/sql, type Out struct, In bool
pkg database/sql, var ErrConnDone error
pkg database/sql/driver, type NamedValueChecker interface { CheckNamedValue }
pkg database/sql/driver, type NamedValueChecker interface, CheckNamedValue(*NamedValue) error
pkg database/sql/driver, var ErrRemoveArgument error
pkg encoding/asn1, const TagNull = 5
pkg encoding/asn1, const TagNull ideal-int
pkg encoding/asn1, var NullBytes []uint8
pkg encoding/asn1, var NullRawValue RawValue
pkg encoding/base32, const NoPadding = -1
pkg encoding/base32, const NoPadding int32
pkg encoding/base32, const StdPadding = 61
pkg encoding/base32, const StdPadding int32
pkg encoding/base32, method (Encoding) WithPadding(int32) *Encoding
pkg encoding/csv, type Reader struct, ReuseRecord bool
pkg encoding/json, func Valid([]uint8) bool
pkg go/ast, type TypeSpec struct, Assign token.Pos
pkg go/types, func SizesFor(string, string) Sizes
pkg go/types, method (*TypeName) IsAlias() bool
pkg hash/fnv, func New128() hash.Hash
pkg hash/fnv, func New128a() hash.Hash
pkg html/template, const ErrPredefinedEscaper = 11
pkg html/template, const ErrPredefinedEscaper ErrorCode
pkg image/png, type Encoder struct, BufferPool EncoderBufferPool
pkg image/png, type EncoderBuffer struct
pkg image/png, type EncoderBufferPool interface { Get, Put }
pkg image/png, type EncoderBufferPool interface, Get() *EncoderBuffer
pkg image/png, type EncoderBufferPool interface, Put(*EncoderBuffer)
pkg math/big, method (*Int) IsInt64() bool
pkg math/big, method (*Int) IsUint64() bool
pkg math/big, type Word uint
pkg math/bits, const UintSize = 64
pkg math/bits, const UintSize ideal-int
pkg math/bits, func LeadingZeros(uint) int
pkg math/bits, func LeadingZeros16(uint16) int
pkg math/bits, func LeadingZeros32(uint32) int
pkg math/bits, func LeadingZeros64(uint64) int
pkg math/bits, func LeadingZeros8(uint8) int
pkg math/bits, func Len(uint) int
pkg math/bits, func Len16(uint16) int
pkg math/bits, func Len32(uint32) int
pkg math/bits, func Len64(uint64) int
pkg math/bits, func Len8(uint8) int
pkg math/bits, func OnesCount(uint) int
pkg math/bits, func OnesCount16(uint16) int
pkg math/bits, func OnesCount32(uint32) int
pkg math/bits, func OnesCount64(uint64) int
pkg math/bits, func OnesCount8(uint8) int
pkg math/bits, func Reverse(uint) uint
pkg math/bits, func Reverse16(uint16) uint16
pkg math/bits, func Reverse32(uint32) uint32
pkg math/bits, func Reverse64(uint64) uint64
pkg math/bits, func Reverse8(uint8) uint8
pkg math/bits, func ReverseBytes(uint) uint
pkg math/bits, func ReverseBytes16(uint16) uint16
pkg math/bits, func ReverseBytes32(uint32) uint32
pkg math/bits, func ReverseBytes64(uint64) uint64
pkg math/bits, func RotateLeft(uint, int) uint
pkg math/bits, func RotateLeft16(uint16, int) uint16
pkg math/bits, func RotateLeft32(uint32, int) uint32
pkg math/bits, func RotateLeft64(uint64, int) uint64
pkg math/bits, func RotateLeft8(uint8, int) uint8
pkg math/bits, func TrailingZeros(uint) int
pkg math/bits, func TrailingZeros16(uint16) int
pkg math/bits, func TrailingZeros32(uint32) int
pkg math/bits, func TrailingZeros64(uint64) int
pkg math/bits, func TrailingZeros8(uint8) int
pkg mime, var ErrInvalidMediaParameter error
pkg mime/multipart, type FileHeader struct, Size int64
pkg mime/multipart, var ErrMessageTooLarge error
pkg net, method (*IPConn) SyscallConn() (syscall.RawConn, error)
pkg net, method (*TCPConn) SyscallConn() (syscall.RawConn, error)
pkg net, method (*UDPConn) SyscallConn() (syscall.RawConn, error)
pkg net, method (*UnixConn) SyscallConn() (syscall.RawConn, error)
pkg net, type Resolver struct, Dial func(context.Context, string, string) (Conn, error)
pkg net, type Resolver struct, StrictErrors bool
pkg net/http, func ServeTLS(net.Listener, Handler, string, string) error
pkg net/http, method (*Server) RegisterOnShutdown(func())
pkg net/http, method (*Server) ServeTLS(net.Listener, string, string) error
pkg net/http/fcgi, func ProcessEnv(*http.Request) map[string]string
pkg net/http/httptest, method (*Server) Certificate() *x509.Certificate
pkg net/http/httptest, method (*Server) Client() *http.Client
pkg reflect, func MakeMapWithSize(Type, int) Value
pkg runtime/pprof, func Do(context.Context, LabelSet, func(context.Context))
pkg runtime/pprof, func ForLabels(context.Context, func(string, string) bool)
pkg runtime/pprof, func Label(context.Context, string) (string, bool)
pkg runtime/pprof, func Labels(...string) LabelSet
pkg runtime/pprof, func SetGoroutineLabels(context.Context)
pkg runtime/pprof, func WithLabels(context.Context, LabelSet) context.Context
pkg runtime/pprof, type LabelSet struct
pkg sync, method (*Map) Delete(interface{})
pkg sync, method (*Map) Load(interface{}) (interface{}, bool)
pkg sync, method (*Map) LoadOrStore(interface{}, interface{}) (interface{}, bool)
pkg sync, method (*Map) Range(func(interface{}, interface{}) bool)
pkg sync, method (*Map) Store(interface{}, interface{})
pkg sync, type Map struct
pkg syscall (darwin-386-cgo), type Credential struct, NoSetGroups bool
pkg syscall (darwin-386), type Credential struct, NoSetGroups bool
pkg syscall (darwin-amd64-cgo), type Credential struct, NoSetGroups bool
pkg syscall (darwin-amd64), type Credential struct, NoSetGroups bool
pkg syscall (freebsd-386-cgo), func Pipe2([]int, int) error
pkg syscall (freebsd-386-cgo), type Credential struct, NoSetGroups bool
pkg syscall (freebsd-386), func Pipe2([]int, int) error
pkg syscall (freebsd-386), type Credential struct, NoSetGroups bool
pkg syscall (freebsd-amd64-cgo), func Pipe2([]int, int) error
pkg syscall (freebsd-amd64-cgo), type Credential struct, NoSetGroups bool
pkg syscall (freebsd-amd64), func Pipe2([]int, int) error
pkg syscall (freebsd-amd64), type Credential struct, NoSetGroups bool
pkg syscall (freebsd-arm-cgo), func Pipe2([]int, int) error
pkg syscall (freebsd-arm-cgo), type Credential struct, NoSetGroups bool
pkg syscall (freebsd-arm), func Pipe2([]int, int) error
pkg syscall (freebsd-arm), type Credential struct, NoSetGroups bool
pkg syscall (linux-386-cgo), type Credential struct, NoSetGroups bool
pkg syscall (linux-386), type Credential struct, NoSetGroups bool
pkg syscall (linux-amd64-cgo), type Credential struct, NoSetGroups bool
pkg syscall (linux-amd64), type Credential struct, NoSetGroups bool
pkg syscall (linux-arm-cgo), type Credential struct, NoSetGroups bool
pkg syscall (linux-arm), type Credential struct, NoSetGroups bool
pkg syscall (netbsd-386-cgo), type Credential struct, NoSetGroups bool
pkg syscall (netbsd-386), type Credential struct, NoSetGroups bool
pkg syscall (netbsd-amd64-cgo), type Credential struct, NoSetGroups bool
pkg syscall (netbsd-amd64), type Credential struct, NoSetGroups bool
pkg syscall (netbsd-arm-cgo), type Credential struct, NoSetGroups bool
pkg syscall (netbsd-arm), type Credential struct, NoSetGroups bool
pkg syscall (openbsd-386-cgo), type Credential struct, NoSetGroups bool
pkg syscall (openbsd-386), type Credential struct, NoSetGroups bool
pkg syscall (openbsd-amd64-cgo), type Credential struct, NoSetGroups bool
pkg syscall (openbsd-amd64), type Credential struct, NoSetGroups bool
pkg syscall (windows-386), const WSAECONNABORTED = 10053
pkg syscall (windows-386), const WSAECONNABORTED Errno
pkg syscall (windows-amd64), const WSAECONNABORTED = 10053
pkg syscall (windows-amd64), const WSAECONNABORTED Errno
pkg syscall, type Conn interface { SyscallConn }
pkg syscall, type Conn interface, SyscallConn() (RawConn, error)
pkg syscall, type RawConn interface { Control, Read, Write }
pkg syscall, type RawConn interface, Control(func(uintptr)) error
pkg syscall, type RawConn interface, Read(func(uintptr) bool) error
pkg syscall, type RawConn interface, Write(func(uintptr) bool) error
pkg testing, method (*B) Helper()
pkg testing, method (*T) Helper()
pkg testing, type TB interface, Helper()
pkg time, method (Duration) Round(Duration) Duration
pkg time, method (Duration) Truncate(Duration) Duration

View File

@@ -20,7 +20,7 @@ trap cleanup 0 INT
rm -f get.bin final-test.bin a.out
# If called with -all, check that all code snippets compile.
if [ "$1" = "-all" ]; then
if [ "$1" == "-all" ]; then
for fn in *.go; do
go build -o a.out $fn
done

View File

@@ -22,7 +22,7 @@ using the go <code>tool</code> subcommand, such as <code>go tool vet</code>.
This style of invocation allows, for instance, checking a single source file
rather than an entire package: <code>go tool vet myprogram.go</code> as
compared to <code>go vet mypackage</code>.
Some of the commands, such as <code>pprof</code>, are accessible only through
Some of the commands, such as <code>yacc</code>, are accessible only through
the go <code>tool</code> subcommand.
</p>
@@ -95,6 +95,12 @@ gofmt</a> command with more general options.</td>
calls whose arguments do not align with the format string.</td>
</tr>
<tr>
<td><a href="/cmd/yacc/">yacc</a></td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>Yacc is a version of yacc that generates parsers implemented in Go.</td>
</tr>
</table>
<p>

View File

@@ -124,12 +124,8 @@ workspace. It defaults to a directory named <code>go</code> inside your home dir
so <code>$HOME/go</code> on Unix,
<code>$home/go</code> on Plan 9,
and <code>%USERPROFILE%\go</code> (usually <code>C:\Users\YourName\go</code>) on Windows.
</p>
<p>
If you would like to work in a different location, you will need to
<a href="https://golang.org/wiki/SettingGOPATH">set <code>GOPATH</code></a>
to the path to that directory.
If you would like to work in a different location, you will need to set
<code>GOPATH</code> to the path to that directory.
(Another common setup is to set <code>GOPATH=$HOME</code>.)
Note that <code>GOPATH</code> must <b>not</b> be the
same path as your Go installation.

View File

@@ -148,26 +148,29 @@ These actions are explicitly forbidden in Go spaces:
<p>
The Go spaces are not free speech venues; they are for discussion about Go.
Each of these spaces have their own moderators.
These spaces have moderators.
The goal of the moderators is to facilitate civil discussion about Go.
</p>
<p>
When using the official Go spaces you should act in the spirit of the “Gopher
values”.
If a reported conflict cannot be resolved amicably, the CoC Working Group
may make a recommendation to the relevant forum moderators.
If you conduct yourself in a way that is explicitly forbidden by the CoC,
you will be warned and asked to stop.
If you do not stop, you will be removed from our community spaces temporarily.
Repeated, willful breaches of the CoC will result in a permanent ban.
</p>
<p>
CoC Working Group members and forum moderators are held to a higher standard than other community members.
If a working group member or moderator creates an inappropriate situation, they
should expect less leeway than others, and should expect to be removed from
their position if they cannot adhere to the CoC.
Moderators are held to a higher standard than other community members.
If a moderator creates an inappropriate situation, they should expect less
leeway than others, and should expect to be removed from their position if they
cannot adhere to the CoC.
</p>
<p>
Complaints about working group member or moderator actions must be handled
using the reporting process below.
Complaints about moderator actions must be handled using the reporting process
below.
</p>
<h2 id="reporting">Reporting issues</h2>
@@ -182,6 +185,8 @@ satisfaction of all parties. They are:
<ul>
<li>Aditya Mukerjee &lt;dev@chimeracoder.net&gt;
<li>Andrew Gerrand &lt;adg@golang.org&gt;
<li>Dave Cheney &lt;dave@cheney.net&gt;
<li>Jason Buberel &lt;jbuberel@google.com&gt;
<li>Peggy Li &lt;peggyli.224@gmail.com&gt;
<li>Sarah Adams &lt;sadams.codes@gmail.com&gt;
<li>Steve Francia &lt;steve.francia@gmail.com&gt;
@@ -196,10 +201,13 @@ particular individual or group.
</p>
<ul>
<li>Mail <a href="mailto:conduct@golang.org">conduct@golang.org</a>.
<li>Mail <a href="mailto:conduct@golang.org">conduct@golang.org</a> or
<a href="https://golang.org/s/conduct-report">submit an anonymous report</a>.
<ul>
<li>Your message will reach the Working Group.
<li>Reports are confidential within the Working Group.
<li>Should you choose to remain anonymous then the Working Group cannot
notify you of the outcome of your report.
<li>You may contact a member of the group directly if you do not feel
comfortable contacting the group as a whole. That member will then raise
the issue with the Working Group as a whole, preserving the privacy of the
@@ -221,8 +229,11 @@ particular individual or group.
<li>The Working Group will reach a decision as to how to act. These may include:
<ul>
<li>Nothing.
<li>Passing the report along to the offender.
<li>A recommendation of action to the relevant forum moderators.
<li>A request for a private or public apology.
<li>A private or public warning.
<li>An imposed vacation (for instance, asking someone to abstain for a week
from a mailing list or IRC).
<li>A permanent or temporary ban from some or all Go spaces.
</ul>
<li>The Working Group will reach out to the original reporter to let them know
the decision.
@@ -235,6 +246,7 @@ particular individual or group.
conflicts in the most harmonious way possible.</b>
We hope that in most cases issues may be resolved through polite discussion and
mutual agreement.
Bannings and other forceful measures are to be employed only as a last resort.
</p>
<p>

View File

@@ -34,7 +34,6 @@ We encourage all Go users to subscribe to
<p>A <a href="/doc/devel/release.html">summary</a> of the changes between Go releases. Notes for the major releases:</p>
<ul>
<li><a href="/doc/go1.8">Go 1.8</a> <small>(February 2017)</small></li>
<li><a href="/doc/go1.7">Go 1.7</a> <small>(August 2016)</small></li>
<li><a href="/doc/go1.6">Go 1.6</a> <small>(February 2016)</small></li>
<li><a href="/doc/go1.5">Go 1.5</a> <small>(August 2015)</small></li>

View File

@@ -1,12 +1,14 @@
<!--{
"Title": "Contribution Guide"
"Title": "Contribution Guidelines"
}-->
<h2 id="Introduction">Introduction</h2>
<p>
The Go project welcomes all contributors. The process of contributing
to the Go project may be different than many projects you are used to.
This document is intended as a guide to help you through the contribution
process. This guide assumes you have a basic understanding of Git and Go.
This document explains how to contribute changes to the Go project.
It assumes you have followed the
<a href="/doc/install/source">installation instructions</a> and
have <a href="code.html">written and tested your code</a>.
</p>
<p>
@@ -18,73 +20,103 @@ see <a href="gccgo_contribute.html">Contributing to gccgo</a>.)
Sensitive security-related issues should be reported to <a href="mailto:security@golang.org">security@golang.org</a>.
</p>
<h1 id="contributor">Becoming a contributor</h1>
<h2 id="Design">Discuss your design</h2>
<p>
Before you can contribute to the Go project you need to setup a few prerequisites.
The Go project uses <a href="https://www.gerritcodereview.com/">Gerrit</a>, an open
source online tool, to perform all code reviews.
Gerrit uses your email address as a unique identifier.
The Go project contributing flow is currently configured to work only with Google Accounts.
You must go through the following process <em>prior to contributing</em>.
You only need to do this once per Google Account.
The project welcomes submissions but please let everyone know what
you're working on if you want to change or add to the Go repositories.
</p>
<h2 id="go-contrib-init">Automatically set up &amp; diagnose your development environment</h3>
<p>
The <code>go-contrib-init</code> tool configures and debugs your Go
development environment, automatically performing many of the steps
on this page, or telling you what you need to do next. If you wish
to use it, run:
Before undertaking to write something new for the Go project,
please <a href="https://golang.org/issue/new">file an issue</a>
(or claim an <a href="https://golang.org/issues">existing issue</a>).
Significant changes must go through the
<a href="https://golang.org/s/proposal-process">change proposal process</a>
before they can be accepted.
</p>
<p>
This process gives everyone a chance to validate the design,
helps prevent duplication of effort,
and ensures that the idea fits inside the goals for the language and tools.
It also checks that the design is sound before code is written;
the code review tool is not the place for high-level discussions.
</p>
<p>
When planning work, please note that the Go project follows a
<a href="https://golang.org/wiki/Go-Release-Cycle">six-month
development cycle</a>. The latter half of each cycle is a three-month
feature freeze during which only bug fixes and doc updates are accepted.
New work cannot be submitted during a feature freeze.
</p>
<h2 id="Testing">Testing redux</h2>
<p>
You've <a href="code.html">written and tested your code</a>, but
before sending code out for review, run all the tests for the whole
tree to make sure the changes don't break other packages or programs:
</p>
<pre>
$ go get -u golang.org/x/tools/cmd/go-contrib-init
$ cd /code/to/edit
$ go-contrib-init
$ cd go/src
$ ./all.bash
</pre>
<p>
The tool will either set things up, tell you that everything is
configured, or tell you what steps you need to do manually.
</p>
<h2 id="auth">Configure Git to use Gerrit</h2>
<p>
You'll need a web browser and a command line terminal.
You should already have Git installed.
(To build under Windows use <code>all.bat</code>.)
</p>
<p>
Gerrit uses Google Accounts for authentication.
If you don't have a Google Account, you can create an account which
After running for a while, the command should print
"<code>ALL</code> <code>TESTS</code> <code>PASSED</code>".
</p>
<h2 id="Code_review">Code review</h2>
<p>
Changes to Go must be reviewed before they are accepted,
no matter who makes the change.
A custom git command called <code>git-codereview</code>,
discussed below, helps manage the code review process through a Google-hosted
<a href="https://go-review.googlesource.com/">instance</a> of the code review
system called <a href="https://www.gerritcodereview.com/">Gerrit</a>.
</p>
<h3 id="auth">Set up authentication for code review</h3>
<p>
Gerrit uses Google Accounts for authentication. If you don't have
a Google Account, you can create an account which
<a href="https://www.google.com/accounts/NewAccount">includes
a new Gmail email account</a> or create an account associated
<a href="https://accounts.google.com/SignUpWithoutGmail">with your existing
email address</a>.
</p>
<h3>Step 1: Sign in to googlesource and generate a password</h3>
<p>
The email address associated with the Google Account you use will be recorded in
the <a href="https://go.googlesource.com/go/+log/">change log</a>
and in the <a href="/CONTRIBUTORS">contributors file</a>.
</p>
<p>
Visit <a href="https://go.googlesource.com">go.googlesource.com</a>
To set up your account in Gerrit, visit
<a href="https://go.googlesource.com">go.googlesource.com</a>
and click on "Generate Password" in the page's top right menu bar.
</p>
<p>
You will be redirected to accounts.google.com to sign in.
</p>
<h3>Step 2: Run the provided script</h3>
<p>
After signing in, you are taken to a page on go.googlesource.com with the title "Configure Git".
This page contains a personalized script which when run locally will configure git
to have your unique authentication key.
This key is paired with one generated server side similar to how ssh keys work.
</p>
<p>
Copy and run this script locally in your command line terminal.
(On a Windows computer using cmd you should instead follow the instructions
in the yellow box to run the command. If you are using git-bash use the same
script as *nix.)
Once signed in, you are returned back to go.googlesource.com to "Configure Git".
Follow the instructions on the page.
(If you are on a Windows computer, you should instead follow the instructions
in the yellow box to run the command.)
</p>
<p>
@@ -92,25 +124,23 @@ Your secret authentication token is now in a <code>.gitcookie</code> file
and Git is configured to use this file.
</p>
<h3 id="gerrit">Step 3: Register with Gerrit</h3>
<h3 id="gerrit">Register with Gerrit</h3>
<p>
Now that you have your authentication token, you need to register your
account with Gerrit.
To do this, visit <a href="https://go-review.googlesource.com/login/">
go-review.googlesource.com/login/</a>.
Sign in using the same Google Account you used above.
Now that you have your authentication token,
you need to register your account with Gerrit.
To do this, visit
<a href="https://go-review.googlesource.com/login/">
go-review.googlesource.com/login/</a>. You will immediately be redirected
to Google Accounts. Sign in using the same Google Account you used above.
That is all that is required.
</p>
<h2 id="cla">Contributor License Agreement</h2>
<h3 id="which_cla">Which CLA</h3>
<p>
Before sending your first change to the Go project
you must have completed one of the following two CLAs.
Which CLA you should sign depends on who owns the copyright to your work.
</p>
<h3 id="cla">Contributor License Agreement</h3>
<p>Gerrit serves as the gatekeeper and uses your e-mail address as the key.
To send your first change to the Go project from a given address,
you must have completed one of the contributor license agreements:
<ul>
<li>
If you are the copyright holder, you will need to agree to the
@@ -121,49 +151,37 @@ contributor license agreement</a>, which can be completed online.
If your organization is the copyright holder, the organization
will need to agree to the
<a href="https://developers.google.com/open-source/cla/corporate">corporate
contributor license agreement</a>.<br>
contributor license agreement</a>.
(If the copyright holder for your code has already completed the
agreement in connection with another Google open source project,
it does not need to be completed again.)
</li>
</ul>
<p>
<i>If the copyright holder for your contribution has already completed the
agreement in connection with another Google open source project,
it does not need to be completed again.</i>
</p>
<h3 id="signing_cla">Completing the CLA</h3>
<p>
You can see your currently signed agreements and sign new ones through the Gerrit
interface.
To do this, <a href="https://go-review.googlesource.com/login/">Log into Gerrit</a>,
then visit the <a href="https://go-review.googlesource.com/settings/agreements">Agreements</a>
page.
If you do not have a signed agreement listed there, you can create one
by clicking "New Contributor Agreement" and following the steps.
You can use the links above to create and sign the contributor license agreement
or you can show your current agreements and create new ones through the Gerrit
interface. <a href="https://go-review.googlesource.com/login/">Log into Gerrit</a>,
click your name in the upper-right, choose "Settings", then select "Agreements"
from the topics on the left. If you do not have a signed agreement listed here,
you can create one by clicking "New Contributor Agreement" and following the steps.
</p>
<p>
If the copyright holder for the code you are submitting changes &mdash; for example,
if you start contributing code on behalf of a new company &mdash; please send email
to golang-dev and let us know, so that we can make sure an appropriate agreement is
completed and update the <code>AUTHORS</code> file.
This rigmarole only needs to be done for your first submission for each email address.
</p>
<span id="Code_review"></span>
<h1 id="prepare_dev_env">Preparing a Development Environment for Contributing</h1>
<h2 id="git-codereview">Setting up Git for submission to Gerrit</h2>
<p>
Changes to Go must be reviewed before they are accepted, no matter who makes the change.
A custom git command called <code>git-codereview</code>, discussed below,
helps manage the code review process through a Google-hosted
<a href="https://go-review.googlesource.com/">instance</a> Gerrit.
If the copyright holder for the code you are submitting changes—for example,
if you start contributing code on behalf of a new company—please send email
to let us know, so that we can make sure an appropriate agreement is completed
and update the <code>AUTHORS</code> file.
</p>
<h3 id="git-codereview_install">Install the git-codereview command</h3>
<h3 id="git-codereview">Install the git-codereview command</h3>
<p>
Install the <code>git-codereview</code> command by running,
Now install the <code>git-codereview</code> command by running,
</p>
<pre>
@@ -183,29 +201,19 @@ $ git codereview help
prints help text, not an error.
</p>
<p>
On Windows, when using git-bash you must make sure that
<code>git-codereview.exe</code> is in your git exec-path.
Run <code>git --exec-path</code> to discover the right location then create a
symbolic link or simply copy the executible from $GOPATH/bin to this directory.
</p>
<p>
<b>Note to Git aficionados:</b>
The <code>git-codereview</code> command is not required to
upload and manage Gerrit code reviews.
For those who prefer plain Git, the text below gives the Git equivalent of
each git-codereview command.
upload and manage Gerrit code reviews. For those who prefer plain Git, the text
below gives the Git equivalent of each git-codereview command.
</p>
<p>
If you do use plain Git, note that you still need the commit hooks that the
git-codereview command configures; those hooks add a Gerrit
<code>Change-Id</code> line to the commit message and check that all Go source
files have been formatted with gofmt.
Even if you intend to use plain Git for
daily work, install the hooks in a new Git checkout by running
<code>git-codereview</code> <code>hooks</code>.
<p>If you do use plain
Git, note that you still need the commit hooks that the git-codereview command
configures; those hooks add a Gerrit <code>Change-Id</code> line to the commit
message and check that all Go source files have been formatted with gofmt. Even
if you intend to use plain Git for daily work, install the hooks in a new Git
checkout by running <code>git-codereview</code> <code>hooks</code>.
</p>
<p>
@@ -256,8 +264,7 @@ To install them, copy this text into your Git configuration file
sync = codereview sync
</pre>
<span id="help"></span>
<h3 id="understanding_git-codereview">Understanding the git-codereview command</h3>
<h3 id="help">Understanding the git-codereview command</h3>
<p>After installing the <code>git-codereview</code> command, you can run</p>
@@ -270,70 +277,11 @@ to learn more about its commands.
You can also read the <a href="https://godoc.org/golang.org/x/review/git-codereview">command documentation</a>.
</p>
<h1 id="making_a_contribution">Making a Contribution</h1>
<h2 id="Design">Discuss your design</h2>
<p>
The project welcomes submissions but please let everyone know what
you're working on if you want to change or add to the Go repositories.
</p>
<p>
Before undertaking to write something new for the Go project,
please <a href="https://golang.org/issue/new">file an issue</a>
(or claim an <a href="https://golang.org/issues">existing issue</a>).
Significant changes must go through the
<a href="https://golang.org/s/proposal-process">change proposal process</a>
before they can be accepted.
</p>
<p>
This process gives everyone a chance to validate the design,
helps prevent duplication of effort,
and ensures that the idea fits inside the goals for the language and tools.
It also checks that the design is sound before code is written;
the code review tool is not the place for high-level discussions.
</p>
<p>
When planning work, please note that the Go project follows a <a
href="https://golang.org/wiki/Go-Release-Cycle">six-month development cycle</a>.
The latter half of each cycle is a three-month feature freeze during
which only bug fixes and doc updates are accepted. New contributions can be
sent during a feature freeze but will not be accepted until the freeze thaws.
</p>
<h2 id="making_a_change">Making a change</h2>
<h3 id="checkout_go">Getting Go Source</h3>
<p>
First you need to have a local copy of the source checked out from the correct
repository.
As Go builds Go you will also likely need to have a working version
of Go installed (some documentation changes may not need this).
This should be a recent version of Go and can be obtained via any package or
binary distribution or you can build it from source.
</p>
<p>
You should checkout the Go source repo anywhere you want as long as it's
outside of your $GOPATH.
Go to a directory where you want the source to appear and run the following
command in a terminal.
</p>
<pre>
$ git clone https://go.googlesource.com/go
$ cd go
</pre>
<h3 id="master">Contributing to the main Go tree</h3>
<h3 id="master">Switch to the master branch</h3>
<p>
Most Go installations use a release branch, but new changes should
only be made based on the master branch. <br>
only be made based on the master branch.
(They may be applied later to a release branch as part of the release process,
but most contributors won't do this themselves.)
Before making a change, make sure you start on the master branch:
@@ -349,61 +297,10 @@ $ git sync
<code>git</code> <code>pull</code> <code>-r</code>.)
</p>
<h3 id="subrepos">Contributing to subrepositories (golang.org/x/...)</h3>
<p>
If you are contributing a change to a subrepository, obtain the
Go package using <code>go get</code>. For example, to contribute
to <code>golang.org/x/oauth2</code>, check out the code by running:
</p>
<pre>
$ go get -d golang.org/x/oauth2/...
</pre>
<p>
Then, change your directory to the package's source directory
(<code>$GOPATH/src/golang.org/x/oauth2</code>).
</p>
<h3 id="change">Make your changes</h3>
<p>
The entire checked-out tree is editable.
Make your changes as you see fit ensuring that you create appropriate
tests along with your changes. Test your changes as you go.
</p>
<h3 id="copyright">Copyright</h3>
<p>
Files in the Go repository don't list author names, both to avoid clutter
and to avoid having to keep the lists up to date.
Instead, your name will appear in the
<a href="https://golang.org/change">change log</a> and in the <a
href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file and perhaps the <a
href="/AUTHORS"><code>AUTHORS</code></a> file.
These files are automatically generated from the commit logs perodically.
The <a href="/AUTHORS"><code>AUTHORS</code></a> file defines who &ldquo;The Go
Authors&rdquo;&mdash;the copyright holders&mdash;are.
</p>
<p>New files that you contribute should use the standard copyright header:</p>
<pre>
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
</pre>
<p>
Files in the repository are copyright the year they are added.
Do not update the copyright year on files that you change.
</p>
<h3 id="commit_changes">Commit your changes</h3>
<h3 id="change">Make a change</h3>
<p>
The entire checked-out tree is writable.
Once you have edited files, you must tell Git that they have been modified.
You must also tell Git about any files that are added, removed, or renamed files.
These operations are done with the usual Git commands,
@@ -414,20 +311,16 @@ and
</p>
<p>
Once you have the changes queued up, you will want to commit them.
In the Go contribution workflow this is done with a <code>git</code>
<code>change</code> command, which creates a local branch and commits the changes
directly to that local branch.
</p>
If you wish to checkpoint your work, or are ready to send the code out for review, run</p>
<pre>
$ git change <i>&lt;branch&gt;</i>
</pre>
<p>
from any directory in your Go repository to commit the changes so far.
The name <i>&lt;branch&gt;</i> is an arbitrary one you choose to identify the
local branch containing your changes and will not be used elsewhere.
This is an offline operation and nothing will be sent to the server yet.
local branch containing your changes.
</p>
<p>
@@ -438,11 +331,9 @@ then <code>git</code> <code>commit</code>.)
</p>
<p>
As the <code>git</code> <code>commit</code> is the final step, Git will open an
editor to ask for a commit message. (It uses the editor named by
the <code>$EDITOR</code> environment variable,
Git will open a change description file in your editor.
(It uses the editor named by the <code>$EDITOR</code> environment variable,
<code>vi</code> by default.)
The file will look like:
</p>
@@ -461,7 +352,7 @@ At the beginning of this file is a blank line; replace it
with a thorough description of your change.
The first line of the change description is conventionally a one-line
summary of the change, prefixed by the primary affected package,
and is used as the subject for code review email.
and is used as the subject for code review mail.
It should complete the sentence "This change modifies Go to _____."
The rest of the description elaborates and should provide context for the
change and explain what it does.
@@ -504,7 +395,7 @@ the command and move that file to a different branch.
<p>
The special notation "Fixes #159" associates the change with issue 159 in the
<a href="https://golang.org/issue/159">Go issue tracker</a>.
When this change is eventually applied, the issue
When this change is eventually submitted, the issue
tracker will automatically mark the issue as fixed.
(There are several such conventions, described in detail in the
<a href="https://help.github.com/articles/closing-issues-via-commit-messages/">GitHub Issue Tracker documentation</a>.)
@@ -515,13 +406,6 @@ Once you have finished writing the commit message,
save the file and exit the editor.
</p>
<p>
You must have the $EDITOR environment variable set properly and working properly (exiting cleanly)
for this operation to succeed.
If you run into any issues at this step, it's likely your editor isn't exiting cleanly.
Try setting a different editor in your $EDITOR environment variable.
</p>
<p>
If you wish to do more editing, re-stage your changes using
<code>git</code> <code>add</code>, and then run
@@ -532,8 +416,8 @@ $ git change
</pre>
<p>
to update the change description and incorporate the staged changes.
The change description contains a <code>Change-Id</code> line near the bottom,
to update the change description and incorporate the staged changes. The
change description contains a <code>Change-Id</code> line near the bottom,
added by a Git commit hook during the initial
<code>git</code> <code>change</code>.
That line is used by Gerrit to match successive uploads of the same change.
@@ -545,44 +429,35 @@ Do not edit or delete it.
runs <code>git</code> <code>commit</code> <code>--amend</code>.)
</p>
<h3 id="Testing">Testing</h3>
<h3 id="mail">Mail the change for review</h3>
<p>
You've <a href="code.html">written and tested your code</a>, but
before sending code out for review, run all the tests for the whole
tree to make sure the changes don't break other packages or programs:
</p>
<pre>
$ cd go/src
$ ./all.bash
</pre>
<p>
(To build under Windows use <code>all.bat</code>.)
</p>
<p>
After running for a while, the command should print
</p>
<pre>
"ALL TESTS PASSED".
</pre>
<h3 id="mail">Send the change for review</h3>
<p>
Once the change is ready, send it for review.
This is similar to a <code>git push</code> in a GitHub style workflow.
This is done via the mail alias setup earlier which despite its name, doesn't
directly mail anything, it simply sends the change to Gerrit via git push.
Once the change is ready, mail it out for review:
</p>
<pre>
$ git mail
</pre>
<p>
You can specify a reviewer or CC interested parties
using the <code>-r</code> or <code>-cc</code> options.
Both accept a comma-separated list of email addresses:
</p>
<pre>
$ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
</pre>
<p>
Unless explicitly told otherwise, such as in the discussion leading
up to sending in the change list, it's better not to specify a reviewer.
All changes are automatically CC'ed to the
<a href="https://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a>
mailing list. If this is your first ever change, there may be a moderation
delay before it appears on the mailing list, to prevent spam.
</p>
<p>
(In Git terms, <code>git</code> <code>mail</code> pushes the local committed
changes to Gerrit using <code>git</code> <code>push</code> <code>origin</code>
@@ -591,7 +466,7 @@ changes to Gerrit using <code>git</code> <code>push</code> <code>origin</code>
<p>
If your change relates to an open issue, please add a comment to the issue
announcing your proposed fix, including a link to your change.
announcing your proposed fix, including a link to your CL.
</p>
<p>
@@ -604,76 +479,7 @@ remote: New Changes:
remote: https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments
</pre>
<h3>Troubleshooting</h3>
<p>
The most common way that the <code>git mail</code> command fails is because the
email address used has not gone through the setup above.
<br>
If you see something like...
</p>
<pre>
remote: Processing changes: refs: 1, done
remote:
remote: ERROR: In commit ab13517fa29487dcf8b0d48916c51639426c5ee9
remote: ERROR: author email address XXXXXXXXXXXXXXXXXXX
remote: ERROR: does not match your user account.
</pre>
<p>
You need to either add the email address listed to the CLA or set this repo to use
another email address already approved.
</p>
<p>
First let's change the email address for this repo so this doesn't happen again.
You can change your email address for this repo with the following command:
</p>
<pre>
$ git config user.email email@address.com
</pre>
<p>
Then change the previous commit to use this alternative email address.
You can do that with:
</p>
<pre>
$ git commit --amend --author="Author Name &lt;email@address.com&gt;"
</pre>
<p>
Finally try to resend with:
</p>
<pre>
$ git mail
</pre>
<h3 id="cc">Specifying a reviewer / CCing others</h3>
<p>
Unless explicitly told otherwise, such as in the discussion leading
up to sending in the change list, it's better not to specify a reviewer.
All changes are automatically CC'ed to the
<a href="https://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a>
mailing list. If this is your first ever change, there may be a moderation
delay before it appears on the mailing list, to prevent spam.
</p>
<p>
You can specify a reviewer or CC interested parties
using the <code>-r</code> or <code>-cc</code> options.
Both accept a comma-separated list of email addresses:
</p>
<pre>
$ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
</pre>
<h2 id="review">Going through the review process</h2>
<h3 id="review">Reviewing code</h3>
<p>
Running <code>git</code> <code>mail</code> will send an email to you and the
@@ -685,15 +491,7 @@ You must reply through the web interface.
(Unlike with the old Rietveld review system, replying by mail has no effect.)
</p>
<h3 id="revise">Revise and resend</h3>
<p>
The Go contribution workflow is optimized for iterative revisions based on
feedback.
It is rare that an initial contribution will be ready to be applied as is.
As you revise your contribution and resend Gerrit will retain a history of
all the changes and comments made in the single URL.
</p>
<h3 id="revise">Revise and upload</h3>
<p>
You must respond to review comments through the web interface.
@@ -736,8 +534,6 @@ $ git sync
<code>git</code> <code>pull</code> <code>-r</code>.)
</p>
<h3 id="resolving_conflicts">Resolving Conflicts</h3>
<p>
If files you were editing have changed, Git does its best to merge the
remote changes into your local changes.
@@ -813,8 +609,8 @@ might turn up:
<p>
Git doesn't show it, but suppose the original text that both edits
started with was 1e8; you changed it to 1e10 and the other change to 1e9,
so the correct answer might now be 1e10.
First, edit the section to remove the markers and leave the correct code:
so the correct answer might now be 1e10. First, edit the section
to remove the markers and leave the correct code:
</p>
<pre>
@@ -843,13 +639,10 @@ restore the change commit.
<h3 id="download">Reviewing code by others</h3>
<p>
As part of the review process reviewers can propose changes directly (in the
GitHub workflow this would be someone else attaching commits to a pull request).
You can import these changes proposed by someone else into your local Git repository.
You can import a change proposed by someone else into your local Git repository.
On the Gerrit review page, click the "Download ▼" link in the upper right
corner, copy the "Checkout" command and run it from your local Git repo. It
should look something like this:
corner, copy the "Checkout" command and run it from your local Git repo.
It should look something like this:
</p>
<pre>
@@ -860,11 +653,11 @@ $ git fetch https://go.googlesource.com/review refs/changes/21/1221/1 &amp;&amp;
To revert, change back to the branch you were working in.
</p>
<h2 id="submit">Apply the change to the master branch</h2>
<h3 id="submit">Submit the change after the review</h3>
<p>
After the code has been <code>LGTM</code>'ed, an approver may
apply it to the master branch using the Gerrit UI.
submit it to the master branch using the Gerrit UI.
There is a "Submit" button on the web page for the change
that appears once the change is approved (marked +2).
</p>
@@ -876,13 +669,41 @@ and the code review will be updated with a link to the change
in the repository.
Since the method used to integrate the changes is "Cherry Pick",
the commit hashes in the repository will be changed by
the "Submit" operation.
the submit operation.
</p>
<h2 id="more">More information</h2>
<h3 id="more">More information</h3>
<p>
In addition to the information here, the Go community maintains a <a
href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page.
In addition to the information here, the Go community maintains a <a href="https://golang.org/wiki/CodeReview">CodeReview</a> wiki page.
Feel free to contribute to this page as you learn the review process.
</p>
<h2 id="copyright">Copyright</h2>
<p>Files in the Go repository don't list author names,
both to avoid clutter and to avoid having to keep the lists up to date.
Instead, your name will appear in the
<a href="https://golang.org/change">change log</a>
and in the <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file
and perhaps the <a href="/AUTHORS"><code>AUTHORS</code></a> file.
</p>
<p>The <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file
defines who the Go contributors&mdash;the people&mdash;are;
the <a href="/AUTHORS"><code>AUTHORS</code></a> file defines
who &ldquo;The Go Authors&rdquo;&mdash;the copyright holders&mdash;are.
These files will be periodically updated based on the commit logs.
<p>Code that you contribute should use the standard copyright header:</p>
<pre>
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
</pre>
<p>
Files in the repository are copyright the year they are added. It is not
necessary to update the copyright year on files that you change.
</p>

View File

@@ -4,8 +4,7 @@
}-->
<p><i>
This applies to the standard toolchain (the <code>gc</code> Go
compiler and tools). Gccgo has native gdb support.
This applies to the <code>gc</code> toolchain. Gccgo has native gdb support.
Besides this overview you might want to consult the
<a href="http://sourceware.org/gdb/current/onlinedocs/gdb/">GDB manual</a>.
</i></p>
@@ -50,14 +49,6 @@ when debugging, pass the flags <code>-gcflags "-N -l"</code> to the
debugged.
</p>
<p>
If you want to use gdb to inspect a core dump, you can trigger a dump
on a program crash, on systems that permit it, by setting
<code>GOTRACEBACK=crash</code> in the environment (see the
<a href="/pkg/runtime/#hdr-Environment_Variables"> runtime package
documentation</a> for more info).
</p>
<h3 id="Common_Operations">Common Operations</h3>
<ul>
@@ -139,7 +130,7 @@ the DWARF code.
<p>
If you're interested in what the debugging information looks like, run
'<code>objdump -W a.out</code>' and browse through the <code>.debug_*</code>
'<code>objdump -W 6.out</code>' and browse through the <code>.debug_*</code>
sections.
</p>
@@ -386,9 +377,7 @@ $3 = struct hchan&lt;*testing.T&gt;
</pre>
<p>
That <code>struct hchan&lt;*testing.T&gt;</code> is the
runtime-internal representation of a channel. It is currently empty,
or gdb would have pretty-printed its contents.
That <code>struct hchan&lt;*testing.T&gt;</code> is the runtime-internal representation of a channel. It is currently empty, or gdb would have pretty-printed it's contents.
</p>
<p>

View File

@@ -15,45 +15,19 @@ git checkout <i>release-branch</i>
<h2 id="policy">Release Policy</h2>
<p>
Each major Go release is supported until there are two newer major releases.
For example, Go 1.8 is supported until Go 1.10 is released,
and Go 1.9 is supported until Go 1.11 is released.
We fix critical problems, including <a href="/security">critical security problems</a>,
in supported releases as needed by issuing minor revisions
(for example, Go 1.8.1, Go 1.8.2, and so on).
</p>
<h2 id="go1.8">go1.8 (released 2017/02/16)</h2>
<p>
Go 1.8 is a major release of Go.
Read the <a href="/doc/go1.8">Go 1.8 Release Notes</a> for more information.
</p>
<h3 id="go1.8.minor">Minor revisions</h3>
<p>
go1.8.1 (released 2017/04/07) includes fixes to the compiler, linker, runtime,
documentation, <code>go</code> command and the <code>crypto/tls</code>,
<code>encoding/xml</code>, <code>image/png</code>, <code>net</code>,
<code>net/http</code>, <code>reflect</code>, <code>text/template</code>,
and <code>time</code> packages.
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.1">Go
1.8.1 milestone</a> on our issue tracker for details.
Each major Go release obsoletes and ends support for the previous one.
For example, if Go 1.5 has been released, then it is the current release
and Go 1.4 and earlier are no longer supported.
We fix critical problems in the current release as needed by issuing minor revisions
(for example, Go 1.5.1, Go 1.5.2, and so on).
</p>
<p>
go1.8.2 (released 2017/05/23) includes a security fix to the
<code>crypto/elliptic</code> package.
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.2">Go
1.8.2 milestone</a> on our issue tracker for details.
</p>
<p>
go1.8.3 (released 2017/05/24) includes fixes to the compiler, runtime,
documentation, and the <code>database/sql</code> package.
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.3">Go
1.8.3 milestone</a> on our issue tracker for details.
As a special case, we issue minor revisions for critical security problems
in both the current release and the previous release.
For example, if Go 1.5 is the current release then we will issue minor revisions
to fix critical security problems in both Go 1.4 and Go 1.5 as they arise.
See the <a href="/security">security policy</a> for more details.
</p>
<h2 id="go1.7">go1.7 (released 2016/08/15)</h2>
@@ -95,20 +69,6 @@ See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.7.4">Go
1.7.4 milestone</a> on our issue tracker for details.
</p>
<p>
go1.7.5 (released 2017/01/26) includes fixes to the compiler, runtime,
and the <code>crypto/x509</code> and <code>time</code> packages.
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.7.5">Go
1.7.5 milestone</a> on our issue tracker for details.
</p>
<p>
go1.7.6 (released 2017/05/23) includes the same security fix as Go 1.8.2 and
was released at the same time.
See the <a href="https://github.com/golang/go/issues?q=milestone%3AGo1.8.2">Go
1.8.2 milestone</a> on our issue tracker for details.
</p>
<h2 id="go1.6">go1.6 (released 2016/02/17)</h2>
<p>

View File

@@ -1580,7 +1580,7 @@ if attended[person] { // will be false if person is not in the map
<p>
Sometimes you need to distinguish a missing entry from
a zero value. Is there an entry for <code>"UTC"</code>
or is that 0 because it's not in the map at all?
or is that the empty string because it's not in the map at all?
You can discriminate with a form of multiple assignment.
</p>
<pre>
@@ -1833,7 +1833,7 @@ for a min function that chooses the least of a list of integers:
</p>
<pre>
func Min(a ...int) int {
min := int(^uint(0) &gt;&gt; 1) // largest int
min := int(^uint(0) >> 1) // largest int
for _, i := range a {
if i &lt; min {
min = i

View File

@@ -52,19 +52,6 @@ user libraries. The Go 1.4 runtime is not fully merged, but that
should not be visible to Go programs.
</p>
<p>
The GCC 6 releases include a complete implementation of the Go 1.6.1
user libraries. The Go 1.6 runtime is not fully merged, but that
should not be visible to Go programs.
</p>
<p>
The GCC 7 releases are expected to include a complete implementation
of the Go 1.8 user libraries. As with earlier releases, the Go 1.8
runtime is not fully merged, but that should not be visible to Go
programs.
</p>
<h2 id="Source_code">Source code</h2>
<p>
@@ -173,6 +160,23 @@ make
make install
</pre>
<h3 id="Ubuntu">A note on Ubuntu</h3>
<p>
Current versions of Ubuntu and versions of GCC before 4.8 disagree on
where system libraries and header files are found. This is not a
gccgo issue. When building older versions of GCC, setting these
environment variables while configuring and building gccgo may fix the
problem.
</p>
<pre>
LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
CPLUS_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
export LIBRARY_PATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH
</pre>
<h2 id="Using_gccgo">Using gccgo</h2>
<p>
@@ -360,15 +364,12 @@ or with C++ code compiled using <code>extern "C"</code>.
<h3 id="Types">Types</h3>
<p>
Basic types map directly: an <code>int32</code> in Go is
an <code>int32_t</code> in C, an <code>int64</code> is
an <code>int64_t</code>, etc.
The Go type <code>int</code> is an integer that is the same size as a
pointer, and as such corresponds to the C type <code>intptr_t</code>.
Go <code>byte</code> is equivalent to C <code>unsigned char</code>.
Pointers in Go are pointers in C.
A Go <code>struct</code> is the same as C <code>struct</code> with the
same fields and types.
Basic types map directly: an <code>int</code> in Go is an <code>int</code>
in C, an <code>int32</code> is an <code>int32_t</code>,
etc. Go <code>byte</code> is equivalent to C <code>unsigned
char</code>.
Pointers in Go are pointers in C. A Go <code>struct</code> is the same as C
<code>struct</code> with the same fields and types.
</p>
<p>
@@ -379,7 +380,7 @@ structure (this is <b style="color: red;">subject to change</b>):
<pre>
struct __go_string {
const unsigned char *__data;
intptr_t __length;
int __length;
};
</pre>
@@ -399,8 +400,8 @@ A slice in Go is a structure. The current definition is
<pre>
struct __go_slice {
void *__values;
intptr_t __count;
intptr_t __capacity;
int __count;
int __capacity;
};
</pre>
@@ -525,3 +526,15 @@ This procedure is full of unstated caveats and restrictions and we make no
guarantee that it will not change in the future. It is more useful as a
starting point for real Go code than as a regular procedure.
</p>
<h2 id="RTEMS_Port">RTEMS Port</h2>
<p>
The gccgo compiler has been ported to <a href="http://www.rtems.com/">
<code>RTEMS</code></a>. <code>RTEMS</code> is a real-time executive
that provides a high performance environment for embedded applications
on a range of processors and embedded hardware. The current gccgo
port is for x86. The goal is to extend the port to most of the
<a href="http://www.rtems.org/wiki/index.php/SupportedCPUs">
architectures supported by <code>RTEMS</code></a>. For more information on the port,
as well as instructions on how to install it, please see this
<a href="http://www.rtems.org/wiki/index.php/GCCGoRTEMS"><code>RTEMS</code> Wiki page</a>.

View File

@@ -15,7 +15,12 @@ Do not send CLs removing the interior tags from such phrases.
ul li { margin: 0.5em 0; }
</style>
<h2 id="introduction">Introduction to Go 1.8</h2>
<h2 id="introduction">DRAFT RELEASE NOTES - Introduction to Go 1.8</h2>
<p><strong>
Go 1.8 is not yet released. These are work-in-progress
release notes. Go 1.8 is expected to be released in February 2017.
</strong></p>
<p>
The latest Go release, version 1.8, arrives six months after <a href="go1.7">Go 1.7</a>.
@@ -88,8 +93,7 @@ On OpenBSD, Go now requires OpenBSD 5.9 or later. <!-- CL 34093 -->
<p>
The Plan 9 port's networking support is now much more complete
and matches the behavior of Unix and Windows with respect to deadlines
and cancelation. For Plan 9 kernel requirements, see the
<a href="https://golang.org/wiki/Plan9">Plan 9 wiki page</a>.
and cancelation.
</p>
<p>
@@ -430,11 +434,11 @@ version of gccgo.
<h3 id="plugin">Plugins</h3>
<p>
Go now provides early support for plugins with a “<code>plugin</code>
build mode for generating plugins written in Go, and a
Go now supports a “<code>plugin</code> build mode for generating
plugins written in Go, and a
new <a href="/pkg/plugin/"><code>plugin</code></a> package for
loading such plugins at run time. Plugin support is currently only
available on Linux. Please report any issues.
loading such plugins at run time. Plugin support is only currently
available on Linux.
</p>
<h2 id="runtime">Runtime</h2>
@@ -794,9 +798,9 @@ Optimizations and minor bug fixes are not listed.
hardware support for AES-GCM is present.
</p>
<p> <!-- CL 27315, CL 35290 -->
<p> <!-- CL 27315 -->
AES-128-CBC cipher suites with SHA-256 are also
now supported, but disabled by default.
now supported.
</p>
</dd>
@@ -804,6 +808,11 @@ Optimizations and minor bug fixes are not listed.
<dl id="crypto_x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
<dd>
<p> <!-- CL 30578 -->
<a href="/pkg/crypto/x509/#SystemCertPool"><code>SystemCertPool</code></a>
is now implemented on Windows.
</p>
<p> <!-- CL 24743 -->
PSS signatures are now supported.
</p>
@@ -854,12 +863,11 @@ crypto/x509: return error for missing SerialNumber (CL 27238)
<p>
The <a href="/pkg/database/sql#IsolationLevel"><code>IsolationLevel</code></a>
can now be set when starting a transaction by setting the isolation level
on <a href="/pkg/database/sql#TxOptions.Isolation"><code>TxOptions.Isolation</code></a> and passing
it to <a href="/pkg/database/sql#DB.BeginTx"><code>DB.BeginTx</code></a>.
on the <code>Context</code> then passing that <code>Context</code> to
<a href="/pkg/database/sql#DB.BeginContext"><code>DB.BeginContext</code></a>.
An error will be returned if an isolation level is selected that the driver
does not support. A read-only attribute may also be set on the transaction
by setting <a href="/pkg/database/sql/#TxOptions.ReadOnly"><code>TxOptions.ReadOnly</code></a>
to true.
with <a href="/pkg/database/sql/#ReadOnlyContext"><code>ReadOnlyContext</code></a>.
</p>
<p>
Queries now expose the SQL column type information for drivers that support it.
@@ -1304,7 +1312,7 @@ crypto/x509: return error for missing SerialNumber (CL 27238)
request must have the new
<a href="/pkg/net/http/#Request"><code>Request.GetBody</code></a>
field defined.
<a href="/pkg/net/http/#NewRequest"><code>NewRequest</code></a>
<a href="pkg/net/http/#NewRequest"><code>NewRequest</code></a>
sets <code>Request.GetBody</code> automatically for common
body types.
</li>
@@ -1609,9 +1617,9 @@ crypto/x509: return error for missing SerialNumber (CL 27238)
June 31 and July 32.
</p>
<p> <!-- CL 33029 --> <!-- CL 34816 -->
<p> <!-- CL 33029 -->
The <code>tzdata</code> database has been updated to version
2016j for systems that don't already have a local time zone
2016i for systems that don't already have a local time zone
database.
</p>
@@ -1641,17 +1649,6 @@ crypto/x509: return error for missing SerialNumber (CL 27238)
and only the overall execution of the test binary would fail.
</p>
<p><!-- CL 32455 -->
The signature of the
<a href="/pkg/testing/#MainStart"><code>MainStart</code></a>
function has changed, as allowed by the documentation. It is an
internal detail and not part of the Go 1 compatibility promise.
If you're not calling <code>MainStart</code> directly but see
errors, that likely means you set the
normally-empty <code>GOROOT</code> environment variable and it
doesn't match the version of your <code>go</code> command's binary.
</p>
</dd>
</dl>

55
doc/go1.8.txt Normal file
View File

@@ -0,0 +1,55 @@
This file lists things yet to be moved into go1.8.html or deemed too
minor to mention. Either way, delete from here when done.
Tools:
go: -buildmode=c-archive now builds PIC on ELF (CL 24180)
go: mobile pkg dir change, recommend using go list in scripts (CL 24930, CL 27929)
go, dist: can set default pkg-config tool using PKG_CONFIG env var (CL 29991)
go: can set secure/insecure GIT schemes using GIT_ALLOW_PROTOCOL env var (CL 30135)
API additions and behavior changes:
cmd/compile, runtime, etc: get rid of constant FP registers (CL 28095)
cmd/compile, runtime: add go:yeswritebarrierrec pragma (CL 30938)
cmd/compile/internal/gc: enable new parser by default (CL 27203)
cmd/compile/internal/syntax: fast Go syntax trees, initial commit (CL 27195)
cmd/compile: add compiler phase timing (CL 24462)
cmd/compile: add inline explainer (CL 22782)
cmd/compile: enable flag-specified dump of specific phase+function (CL 23044)
cmd/internal/obj, cmd/link: darwin dynlink support (CL 29393)
cmd/internal/objfile: add ppc64/ppc64le disassembler support (CL 9682)
cmd/link, cmd/go: delay linking of mingwex and mingw32 until very end (CL 26670)
cmd/link: R_ADDR dynamic relocs for internal PIE (CL 29118)
cmd/link: add trampolines for too far calls in ppc64x (CL 30850)
cmd/link: allow internal PIE linking (CL 28543)
cmd/link: fix -X importpath.name=value when import path needs escaping (CL 31970)
cmd/link: fix -buildmode=pie / -linkshared combination (CL 28996)
cmd/link: for -buildmode=exe pass -no-pie to external linker (CL 33106)
cmd/link: insert trampolines for too-far jumps on ARM (CL 29397)
cmd/link: non-executable stack support for Solaris (CL 24142)
cmd/link: put text at address 0x1000000 on darwin/amd64 (CL 32185)
cmd/link: remove the -shared flag (CL 28852)
cmd/link: split large elf text sections on ppc64x (CL 27790)
cmd/link: trampoline support for external linking on ARM (CL 31143)
cmd/objdump: implement objdump of .o files (CL 24818)
go/build: allow % in ${SRCDIR} expansion for Jenkins (CL 31611)
go/build: do not record go:binary-only-package if build tags not satisfied (CL 31577)
go/build: implement default GOPATH (CL 32019)
runtime/race: update race runtime (CL 32160)
runtime: assume 64kB physical pages on ARM (CL 25021)
runtime: disable stack rescanning by default (CL 31766)
runtime: don't call cgocallback from signal handler (CL 30218)
runtime: fix check for vacuous page boundary rounding (CL 27230)
runtime: fix map iterator concurrent map check (CL 24749)
runtime: fix newextram PC passed to race detector (CL 29712)
runtime: implement unconditional hybrid barrier (CL 31765)
runtime: include pre-panic/throw logs in core dumps (CL 32013)
runtime: limit the number of map overflow buckets (CL 25049)
runtime: pass windows float syscall args via XMM (CL 32173)
runtime: print sigcode on signal crash (CL 32183)
runtime: record current PC for SIGPROF on non-Go thread (CL 30252)
runtime: sleep on CLOCK_MONOTONIC in futexsleep1 on freebsd (CL 30154)

View File

@@ -1,746 +0,0 @@
<!--{
"Title": "Go 1.9 Release Notes",
"Path": "/doc/go1.9",
"Template": true
}-->
<!--
NOTE: In this document and others in this directory, the convention is to
set fixed-width phrases with non-fixed-width spaces, as in
<code>hello</code> <code>world</code>.
Do not send CLs removing the interior tags from such phrases.
-->
<style>
ul li { margin: 0.5em 0; }
</style>
<h2 id="introduction">DRAFT RELEASE NOTES - Introduction to Go 1.9</h2>
<p><strong>
Go 1.9 is not yet released. These are work-in-progress
release notes. Go 1.9 is expected to be released in August 2017.
</strong></p>
<p>
The latest Go release, version 1.9, arrives six months
after <a href="go1.8">Go 1.8</a> and is the tenth release in
the <a href="https://golang.org/doc/devel/release.html">Go 1.x
series</a>.
There is one <a href="#language">change to the language</a>, adding
support for type aliases.
Most of the changes are in the implementation of the toolchain,
runtime, and libraries.
As always, the release maintains the Go 1
<a href="/doc/go1compat.html">promise of compatibility</a>.
We expect almost all Go programs to continue to compile and run as
before.
</p>
<p>
The release
adds <a href="#monotonic-time">transparent monotonic time support</a>,
<a href="#parallel-compile">parallelizes compilation of functions</a> within a package,
better supports <a href="#test-helper">test helper functions</a>,
includes a new <a href="#math-bits">bit manipulation package</a>,
and has a new <a href="#sync-map">concurrent map type</a>.
</p>
<h2 id="language">Changes to the language</h2>
<p>
There is one change to the language.
Go now supports type aliases to support gradual code repair while
moving a type between packages.
The <a href="https://golang.org/design/18130-type-alias">type alias
design document</a>
and <a href="https://talks.golang.org/2016/refactor.article">an
article on refactoring</a> cover the problem in detail.
In short, a type alias declaration has the form:
</p>
<pre>
type T1 = T2
</pre>
<p>
This declaration introduces an alias name <code>T1</code>—an
alternate spelling—for the type denoted by <code>T2</code>; that is,
both <code>T1</code> and <code>T2</code> denote the same type.
</p>
<h2 id="ports">Ports</h2>
<p>
There are no new supported operating systems or processor
architectures in this release.
</p>
<h3 id="power8">ppc64x requires Power8</h3>
<p> <!-- CL 36725, CL 36832 -->
Both <code>GOARCH=ppc64</code> and <code>GOARCH=ppc64le</code> now
require at least Power8 support. In previous releases,
only <code>GOARCH=ppc64le</code> required Power8 and the big
endian <code>ppc64</code> architecture supported older
hardware.
<p>
<h3 id="known_issues">Known Issues</h3>
<p>
There are some instabilities on FreeBSD that are known but not understood.
These can lead to program crashes in rare cases.
See <a href="https://golang.org/issue/15658">issue 15658</a>.
Any help in solving this FreeBSD-specific issue would be appreciated.
</p>
<h2 id="tools">Tools</h2>
<h3 id="parallel-compile">Parallel Compilation</h3>
<p>
The Go compiler now supports compiling a package's functions in parallel, taking
advantage of multiple cores. This is in addition to the <code>go</code> command's
existing support for parallel compilation of separate packages.
Parallel compilation is on by default, but can be disabled by setting the
environment variable <code>GO19CONCURRENTCOMPILATION</code> to <code>0</code>.
</p>
<h3 id="compiler">Compiler Toolchain</h3>
<p><!-- CL 37441 -->
Complex division is now C99-compatible. This has always been the
case in gccgo and is now fixed in the gc toolchain.
</p>
<p> <!-- CL 36983 -->
The linker will now generate DWARF information for cgo executables on Windows.
</p>
<p> <!-- CL 44210, CL 40095 -->
The compiler now includes lexical scopes in the generated DWARF, allowing
debuggers to hide variables that are not in scope. The <code>.debug_info</code>
section is now DWARF version 4.
</p>
<h3 id="go-test-list">Go test</h3>
<p> <!-- CL 41195 -->
The <a href="/cmd/go/#hdr-Description_of_testing_flags"><code>go</code> <code>test</code></a>
command accepts a new <code>-list</code> flag, which takes a regular
expression as an argument and prints to stdout the name of any
tests, benchmarks, or examples that match it, without running them.
</p>
<!-- CL 42028: https://golang.org/cl/42028: cmd/asm: fix operand order of ARM's MULA instruction -->
<!-- CL 36031: https://golang.org/cl/36031: cmd/doc: truncate long lists of arguments -->
<!-- CL 38438: https://golang.org/cl/38438: cmd/doc: implement "go doc struct.field" -->
<!-- CL 38745: https://golang.org/cl/38745: cmd/go: exclude vendored packages from ... matches -->
<!-- CL 38757: https://golang.org/cl/38757: cmd/go: add -json flag to go env -->
<!-- CL 40112: https://golang.org/cl/40112: cmd/go: allow full flag processing in go vet -->
<!-- CL 43855: https://golang.org/cl/43855: cmd/go: include GOARM and GO386 in computed build ID -->
<!-- CL 42990: https://golang.org/cl/42990: cmd/internal/obj/x86: add ADDSUBPS/PD -->
<!-- CL 40331: https://golang.org/cl/40331: cmd/link,runtime/cgo: enable PT_TLS generation on OpenBSD -->
<!-- CL 38343: https://golang.org/cl/38343: cmd/pprof: use proxy from environment -->
<h2 id="performance">Performance</h2>
<p>
As always, the changes are so general and varied that precise
statements about performance are difficult to make. Most programs
should run a bit faster, due to speedups in the garbage collector,
better generated code, and optimizations in the core library.
</p>
<p> <!-- CL 39203 -->
TODO: There have been significant optimizations bringing more than 10% improvements
to implementations in the
<a href="/pkg/encoding/gob"><code>encoding/gob</code></a>, and ...
packages.
</p>
<h3 id="gc">Garbage Collector</h3>
<p> <!-- CL 37520 -->
Library functions that used to trigger stop-the-world garbage
collection now trigger concurrent garbage collection.
Specifically, <a href="/pkg/runtime/#GC"><code>runtime.GC</code></a>,
<a href="/pkg/runtime/debug/#SetGCPercent"><code>debug.SetGCPercent</code></a>,
and
<a href="/pkg/runtime/debug/#FreeOSMemory"><code>debug.FreeOSMemory</code></a>,
now trigger concurrent garbage collection, blocking only the calling
goroutine until the garbage collection is done.
</p>
<p> <!-- CL 34103, CL 39835 -->
The
<a href="/pkg/runtime/debug/#SetGCPercent"><code>debug.SetGCPercent</code></a>
function only triggers a garbage collection if one is immediately
necessary because of the new GOGC value.
This makes it possible to adjust GOGC on-the-fly.
</p>
<p> <!-- CL 38732 -->
Large object allocation performance is significantly improved in
applications using large (&gt;50GB) heaps containing many large
objects.
</p>
<p> <!-- CL 34937 -->
The <a href="/pkg/runtime/#ReadMemStats"><code>runtime.ReadMemStats</code></a>
function now takes less than 100µs even for very large heaps.
</p>
<h2 id="library">Core library</h2>
<h3 id="monotonic-time">Transparent Monotonic Time support</h3>
<p> <!-- CL 36255 -->
The <a href="/pkg/time/"><code>time</code></a> package now transparently
tracks monotonic time in each <a href="/pkg/time/#Time"><code>Time</code></a>
value, making computing durations between two <code>Time</code> values
a safe operation in the presence of wall clock adjustments.
See the <a href="/pkg/time/#hdr-Monotonic_Clocks">package docs</a> and
<a href="https://golang.org/design/12914-monotonic">design document</a>
for details.
</p>
<h3 id="math-bits">New bit manipulation package</h3>
<p> <!-- CL 36315 -->
Go 1.9 includes a new package,
<a href="/pkg/math/bits/"><code>math/bits</code></a>, with optimized
implementations for manipulating bits. On most architectures
functions in this package are additionally recognized by the
compiler and treated as intrinsics for additional performance.
</p>
<h3 id="test-helper">Test Helper Functions</h3>
<p> <!-- CL 38796 -->
The
new <a href="/pkg/testing/#T.Helper"><code>(*T).Helper</code></a>
an <a href="/pkg/testing/#B.Helper"><code>(*B).Helper</code></a>
methods mark the calling function as a test helper function. When
printing file and line information, that function will be skipped.
This permits writing test helper functions while still having useful
line numbers for users.
</p>
<h3 id="sync-map">Concurrent Map</h3>
<p> <!-- CL 36617 -->
The new <a href="/pkg/sync/#Map"><code>Map</code></a> type
in the <a href="/pkg/sync/"><code>sync</code></a> package
is a concurrent map with amortized-constant-time loads, stores, and
deletes. It is safe for multiple goroutines to call a Map's methods
concurrently.
</p>
<h3 id="minor_library_changes">Minor changes to the library</h3>
<p>
As always, there are various minor changes and updates to the library,
made with the Go 1 <a href="/doc/go1compat">promise of compatibility</a>
in mind.
</p>
<dl id="archive/zip"><dt><a href="/pkg/archive/zip/">archive/zip</a></dt>
<dd>
<p><!-- CL 39570 -->
The
ZIP <a href="/pkg/archive/zip/#Writer"><code>Writer</code></a>
now sets the UTF-8 bit in
the <a href="/pkg/archive/zip/#FileHeader.Flags"><code>FileHeader.Flags</code></a>
when appropriate.
</p>
</dl><!-- archive/zip -->
<dl id="crypto/rand"><dt><a href="/pkg/crypto/rand/">crypto/rand</a></dt>
<dd>
<p><!-- CL 43852 -->
On Linux, Go now calls the <code>getrandom</code> system call
without the <code>GRND_NONBLOCK</code> flag; it will now block
until the kernel has sufficient randomness. On kernels predating
the <code>getrandom</code> system call, Go continues to read
from <code>/dev/urandom</code>.
</p>
</dl><!-- crypto/rand -->
<dl id="crypto/x509"><dt><a href="/pkg/crypto/x509/">crypto/x509</a></dt>
<dd>
<p><!-- CL 36093 -->
On Unix systems the environment
variables <code>SSL_CERT_FILE</code>
and <code>SSL_CERT_DIR</code> can now be used to override the
system default locations for the SSL certificate file and SSL
certificate files directory, respectively.
</p>
<p>The FreeBSD path <code>/usr/local/etc/ssl/cert.pem</code> is
now included in the certificate search path.
</p>
<p><!-- CL 36900 -->
The package now supports excluded domains in name constraints.
In addition to enforcing such constraints,
<a href="/pkg/crypto/x509/#CreateCertificate"><code>CreateCertificate</code></a>
will create certificates with excluded name constraints
if the provided template certificate has the new
field
<a href="/pkg/crypto/x509/#Certificate.ExcludedDNSDomains"><code>ExcludedDNSDomains</code></a>
populated.
</p>
</dl><!-- crypto/x509 -->
<dl id="database/sql"><dt><a href="/pkg/database/sql/">database/sql</a></dt>
<dd>
<p><!-- CL 35476 -->
The package will now use a cached <a href="/pkg/database/sql/#Stmt"><code>Stmt</code></a> if
available in <a href="/pkg/database/sql/#Tx.Stmt"><code>Tx.Stmt</code></a>.
This prevents statements from being re-prepared each time
<a href="/pkg/database/sql/#Tx.Stmt"><code>Tx.Stmt</code></a> is called.
</p>
<p><!-- CL 38533 -->
The package now allows drivers to implement their own argument checkers by implementing
<a href="/pkg/database/sql/driver/#NamedValueChecker"><code>driver.NamedValueChecker</code></a>.
This also allows drivers to support <code>OUTPUT</code> and <code>INOUT</code> parameter types.
<a href="/pkg/database/sql/#Out"><code>Out</code></a> should be used to return output parameters
when supported by the driver.
</p>
<p><!-- CL 39031 -->
<a href="/pkg/database/sql/#Rows.Scan"><code>Rows.Scan</code></a> can now scan user-defined string types.
Previously the package supported scanning into numeric types like <code>type Int int64</code>. It now also supports
scanning into string types like <code>type String string</code>.
</p>
<p><!-- CL 40694 -->
The new <a href="/pkg/database/sql/#DB.Conn"><code>DB.Conn</code></a> method returns the new
<a href="/pkg/database/sql/#Conn"><code>Conn</code></a> type representing an
exclusive connection to the database from the connection pool. All queries run on
a <a href="/pkg/database/sql/#Conn"><code>Conn</code></a> will use the same underlying
connection until <a href="/pkg/database/sql/#Conn.Close"><code>Conn.Close</code></a> is called
to return the connection to the connection pool.
</p>
</dl><!-- database/sql -->
<dl id="encoding/asn1"><dt><a href="/pkg/encoding/asn1/">encoding/asn1</a></dt>
<dd>
<p><!-- CL 38660 -->
The new
<a href="/pkg/encoding/asn1/#NullBytes"><code>NullBytes</code></a>
and
<a href="/pkg/encoding/asn1/#NullRawValue"><code>NullRawValue</code></a>
represent the <code>ASN.1 NULL</code> type.
</p>
</dl><!-- encoding/asn1 -->
<dl id="encoding/base32"><dt><a href="/pkg/encoding/base32/">encoding/base32</a></dt>
<dd>
<p><!-- CL 38634 -->
The new <a href="/pkg/encoding/base32/#Encoding.WithPadding">Encoding.WithPadding</a>
method adds support for custom padding characters and disabling padding.
</p>
</dl><!-- encoding/base32 -->
<dl id="fmt"><dt><a href="/pkg/fmt/">fmt</a></dt>
<dd>
<p><!-- CL 37051 -->
The sharp flag ('<code>#</code>') is now supported when printing
floating point and complex numbers. It will always print a
decimal point
for <code>%e</code>, <code>%E</code>, <code>%f</code>, <code>%F</code>, <code>%g</code>
and <code>%G</code>; it will not remove trailing zeros
for <code>%g</code> and <code>%G</code>.
</p>
</dl><!-- fmt -->
<dl id="hash/fnv"><dt><a href="/pkg/hash/fnv/">hash/fnv</a></dt>
<dd>
<p><!-- CL 38356 -->
The package now includes 128-bit FNV-1 and FNV-1a hash support with
<a href="/pkg/hash/fnv/#New128"><code>New128</code></a> and
<a href="/pkg/hash/fnv/#New128a"><code>New128a</code></a>, respectively.
</p>
</dl><!-- hash/fnv -->
<dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
<dd>
<p><!-- CL 37880, CL 40936 -->
The package now reports an error if a predefined escaper (one of
"html", "urlquery" and "js") is found in a pipeline and its
rewriting by the contextual auto-escaper could potentially lead
to security or correctness issues.
</p>
</dl><!-- html/template -->
<dl id="image"><dt><a href="/pkg/image/">image</a></dt>
<dd>
<p><!-- CL 36734 -->
The <a href="/pkg/image/#Rectangle.Intersect"><code>Rectangle.Intersect</code></a>
method now returns a zero <code>Rectangle</code> when called on
adjacent but non-overlapping rectangles, as documented. In
earlier releases it would incorrectly return an empty but
non-zero <code>Rectangle</code>.
</p>
</dl><!-- image -->
<dl id="image/color"><dt><a href="/pkg/image/color/">image/color</a></dt>
<dd>
<p><!-- CL 36732 -->
The YCbCr to RGBA conversion formula has been tweaked to ensure
that rounding adjustments span the complete [0, 0xffff] RGBA
range.
</p>
</dl><!-- image/color -->
<dl id="image/png"><dt><a href="/pkg/image/png/">image/png</a></dt>
<dd>
<p><!-- CL 34150 -->
The new <a href="/pkg/image/png/#Encoder.BufferPool"><code>Encoder.BufferPool</code></a>
field allows specifying an <a href="/pkg/image/png/#EncoderBufferPool"><code>EncoderBufferPool</code></a>,
that will be used by the encoder to get temporary <code>EncoderBuffer</code>
buffers when encoding a PNG image.
The use of a <code>BufferPool</code> reduces the number of
memory allocations performed while encoding multiple images.
</p>
<p><!-- CL 38271 -->
The package now supports the decoding of transparent 8-bit
grayscale ("Gray8") images.
</p>
</dl><!-- image/png -->
<dl id="math/big"><dt><a href="/pkg/math/big/">math/big</a></dt>
<dd>
<p><!-- CL 36487 -->
The new
<a href="/pkg/math/big/#Int.IsInt64"><code>IsInt64</code></a>
and
<a href="/pkg/math/big/#Int.IsUint64"><code>IsUint64</code></a>
methods report whether an <code>Int</code>
may be represented as an <code>int64</code> or <code>uint64</code>
value.
</p>
</dl><!-- math/big -->
<dl id="mime/multipart"><dt><a href="/pkg/mime/multipart/">mime/multipart</a></dt>
<dd>
<p><!-- CL 39223 -->
The new
<a href="/pkg/mime/multipart/#FileHeader.Size"><code>FileHeader.Size</code></a>
field describes the size of a file in a multipart message.
</p>
</dl><!-- mime/multipart -->
<dl id="net"><dt><a href="/pkg/net/">net</a></dt>
<dd>
<p><!-- CL 32572 -->
TODO: <a href="https://golang.org/cl/32572">https://golang.org/cl/32572</a>: add Resolver.StrictErrors
</p>
<p><!-- CL 37260 -->
TODO: <a href="https://golang.org/cl/37260">https://golang.org/cl/37260</a>: allow Resolver to use a custom dialer
</p>
<p><!-- CL 37402 -->
TODO: <a href="https://golang.org/cl/37402">https://golang.org/cl/37402</a>: implement deadline functionality on Pipe
</p>
<p><!-- CL 40510 -->
TODO: <a href="https://golang.org/cl/40510">https://golang.org/cl/40510</a>: don&#39;t enclose non-literal IPv6 addresses in square brackets
</p>
<p><!-- CL 40512 -->
TODO: <a href="https://golang.org/cl/40512">https://golang.org/cl/40512</a>: validate network in Dial{,IP} and Listen{Packet,IP} for IP networks
</p>
<p><!-- CL 37913 -->
The new methods
<a href="/pkg/net/#TCPConn.SyscallConn"><code>TCPConn.SyscallConn</code></a>,
<a href="/pkg/net/#IPConn.SyscallConn"><code>IPConn.SyscallConn</code></a>,
<a href="/pkg/net/#UDPConn.SyscallConn"><code>UDPConn.SyscallConn</code></a>,
and
<a href="/pkg/net/#UnixConn.SyscallConn"><code>UnixConn.SyscallConn</code></a>
provide access to the connections' underlying file descriptors.
</p>
</dl><!-- net -->
<dl id="net/http"><dt><a href="/pkg/net/http/">net/http</a></dt>
<dd>
<p>Server changes:</p>
<ul>
<li><!-- CL 38194 -->
<a href="/pkg/net/http/#ServeMux"><code>ServeMux</code></a> now ignores ports in the host
header when matching handlers. The host is matched unmodified for <code>CONNECT</code> requests.
</li>
<li><!-- CL 34727 -->
<a href="/pkg/net/http/#Server.WriteTimeout"><code>Server.WriteTimeout</code></a>
now applies to HTTP/2 connections and is enforced per-stream.
</li>
<li><!-- CL 43231 -->
HTTP/2 now uses the priority write scheduler by default.
Frames are scheduled by following HTTP/2 priorities as described in
<a href="https://tools.ietf.org/html/rfc7540#section-5.3">RFC 7540 Section 5.3</a>.
</li>
</ul>
<p>Client &amp; Transport changes:</p>
<ul>
<li><!-- CL 35488 -->
The <a href="/pkg/net/http/#Transport"><code>Transport</code></a>
now supports making requests via SOCKS5 proxy when the URL returned by
<a href="/net/http/#Transport.Proxy"><code>Transport.Proxy</code></a>
has the scheme <code>socks5</code>.
</li>
</ul>
</dl><!-- net/http -->
<dl id="net/http/fcgi"><dt><a href="/pkg/net/http/fcgi/">net/http/fcgi</a></dt>
<dd>
<p><!-- CL 40012 -->
The new
<a href="/pkg/net/http/fcgi/#ProcessEnv"><code>ProcessEnv</code></a>
function returns FastCGI environment variables associated with an HTTP request
for which there are no appropriate
<a href="/pkg/net/http/#Request"><code>http.Request</code></a>
fields, such as <code>REMOTE_USER</code>.
</p>
</dl><!-- net/http/fcgi -->
<dl id="net/http/httptest"><dt><a href="/pkg/net/http/httptest/">net/http/httptest</a></dt>
<dd>
<p><!-- CL 34639 -->
The new
<a href="/pkg/net/http/httptest/#Server.Client"><code>Server.Client</code></a>
method returns an HTTP client configured for making requests to the test server.
</p>
<p>
The new
<a href="/pkg/net/http/httptest/#Server.Certificate"><code>Server.Certificate</code></a>
method returns the test server's TLS certificate, if any.
</p>
</dl><!-- net/http/httptest -->
<dl id="net/rpc"><dt><a href="/pkg/net/rpc/">net/rpc</a></dt>
<dd>
<p><!-- CL 38474 -->
TODO: <a href="https://golang.org/cl/38474">https://golang.org/cl/38474</a>: Create empty maps and slices as return type
</p>
</dl><!-- net/rpc -->
<dl id="os"><dt><a href="/pkg/os/">os</a></dt>
<dd>
<p><!-- CL 37915 -->
TODO: <a href="https://golang.org/cl/37915">https://golang.org/cl/37915</a>: parse command line without shell32.dll
</p>
<p><!-- CL 41830 -->
TODO: <a href="https://golang.org/cl/41830">https://golang.org/cl/41830</a>: do not report ModeDir for symlinks on windows
</p>
</dl><!-- os -->
<dl id="os/exec"><dt><a href="/pkg/os/exec/">os/exec</a></dt>
<dd>
<p><!-- CL 37586 -->
The <code>os/exec</code> package now prevents child processes from being created with
any duplicate environment variables.
If <a href="/pkg/os/exec/#Cmd.Env"><code>Cmd.Env</code></a>
contains duplicate environment keys, only the last
value in the slice for each duplicate key is used.
</p>
</dl><!-- os/exec -->
<dl id="os/user"><dt><a href="/pkg/os/user/">os/user</a></dt>
<dd>
<p><!-- CL 37664 -->
<a href="/pkg/os/user/#Lookup"><code>Lookup</code></a> and
<a href="/pkg/os/user/#LookupId"><code>LookupId</code></a> now
work on Unix systems when <code>CGO_ENABLED=0</code> by reading
the <code>/etc/passwd</code> file.
</p>
<p><!-- CL 33713 -->
<a href="/pkg/os/user/#LookupGroup"><code>LookupGroup</code></a> and
<a href="/pkg/os/user/#LookupGroupId"><code>LookupGroupId</code></a> now
work on Unix systems when <code>CGO_ENABLED=0</code> by reading
the <code>/etc/group</code> file.
</p>
</dl><!-- os/user -->
<dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt>
<dd>
<p><!-- CL 38335 -->
The new
<a href="/pkg/reflect/#MakeMapWithSize"><code>MakeMapWithSize</code></a>
function creates a map with a capacity hint.
</p>
</dl><!-- reflect -->
<dl id="runtime"><dt><a href="/pkg/runtime/">runtime</a></dt>
<dd>
<p><!-- CL 37233, CL 37726 -->
Tracebacks generated by the runtime and recorded in profiles are
now accurate in the presence of inlining.
To retrieve tracebacks programmatically, applications should use
<a href="/pkg/runtime/#CallersFrames"><code>runtime.CallersFrames</code></a>
rather than directly iterating over the results of
<a href="/pkg/runtime/#Callers"><code>runtime.Callers</code></a>.
</p>
<p><!-- CL 38403 -->
On Windows, Go no longer forces the system timer to run at high
resolution when the program is idle.
This should reduce the impact of Go programs on battery life.
</p>
<p><!-- CL 29341 -->
On FreeBSD, <code>GOMAXPROCS</code> and
<a href="/pkg/runtime/#NumCPU"><code>runtime.NumCPU</code></a>
are now based on the process' CPU mask, rather than the total
number of CPUs.
</p>
<p><!-- CL 43641 -->
The runtime has preliminary support for Android O.
</p>
</dl><!-- runtime -->
<dl id="runtime/pprof"><dt><a href="/pkg/runtime/pprof/">runtime/pprof</a></dt>
<dd>
<p><!-- CL 34198 -->
TODO: <a href="https://golang.org/cl/34198">https://golang.org/cl/34198</a>: add definitions of profile label types
</p>
</dl><!-- runtime/pprof -->
<dl id="runtime/trace"><dt><a href="/pkg/runtime/trace/">runtime/trace</a></dt>
<dd>
<p><!-- CL 36015 -->
The execution trace now displays mark assist events, which
indicate when an application goroutine is forced to assist
garbage collection because it is allocating too quickly.
</p>
<p><!-- CL 40810 -->
"Sweep" events now encompass the entire process of finding free
space for an allocation, rather than recording each individual
span that is swept.
This reduces allocation latency when tracing allocation-heavy
programs.
The sweep event shows how many bytes were swept and how many
were reclaimed.
</p>
</dl><!-- runtime/trace -->
<dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
<dd>
<p><!-- CL 34310 -->
<a href="/pkg/sync/#Mutex"><code>Mutex</code></a> is now more fair.
</p>
</dl><!-- sync -->
<dl id="syscall"><dt><a href="/pkg/syscall/">syscall</a></dt>
<dd>
<p><!-- CL 36697 -->
The new field
<a href="/pkg/syscall/#Credential.NoSetGroups"><code>Credential.NoSetGroups</code></a>
controls whether Unix systems make a <code>setgroups</code> system call
to set supplementary groups when starting a new process.
</p>
<p><!-- CL 37439 -->
On 64-bit x86 Linux, process creation latency has been optimized with
use of <code>CLONE_VFORK</code> and <code>CLONE_VM</code>.
</p>
<p><!-- CL 37913 -->
The new
<a href="/pkg/syscall/#Conn"><code>Conn</code></a>
interface describes some types in the
<a href="/pkg/net/"><code>net</code></a>
package that can provide access to their underlying file descriptor
using the new
<a href="/pkg/syscall/#RawConn"><code>RawConn</code></a>
interface.
</p>
</dl><!-- syscall -->
<dl id="testing/quick"><dt><a href="/pkg/testing/quick/">testing/quick</a></dt>
<dd>
<p><!-- CL 39152 -->
The package now chooses values in the full range when
generating <code>int64</code> and <code>uint64</code> random
numbers; in earlier releases generated values were always
limited to the [-2<sup>62</sup>, 2<sup>62</sup>) range.
</p>
</dl><!-- testing/quick -->
<dl id="text/template"><dt><a href="/pkg/text/template/">text/template</a></dt>
<dd>
<p><!-- CL 38420 -->
The handling of empty blocks, which was broken by a Go 1.8
change that made the result dependent on the order of templates,
has been fixed, restoring the old Go 1.7 behavior.
</p>
</dl><!-- text/template -->
<dl id="time"><dt><a href="/pkg/time/">time</a></dt>
<dd>
<p><!-- CL 36615 -->
The new methods
<a href="/pkg/time/#Duration.Round"><code>Duration.Round</code></a>
and
<a href="/pkg/time/#Duration.Truncate"><code>Duration.Truncate</code></a>
handle rounding durations away from and towards zero, respectively.
</p>
<p><!-- CL 35710 -->
Retrieving the time and sleeping now work correctly under Wine.
</p>
</dl><!-- time -->

View File

@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Version of June 7, 2017",
"Subtitle": "Version of November 18, 2016",
"Path": "/ref/spec"
}-->
@@ -154,7 +154,7 @@ Any other comment acts like a newline.
<p>
Tokens form the vocabulary of the Go language.
There are four classes: <i>identifiers</i>, <i>keywords</i>, <i>operators
and punctuation</i>, and <i>literals</i>. <i>White space</i>, formed from
and delimiters</i>, and <i>literals</i>. <i>White space</i>, formed from
spaces (U+0020), horizontal tabs (U+0009),
carriage returns (U+000D), and newlines (U+000A),
is ignored except as it separates tokens
@@ -197,7 +197,7 @@ into the token stream immediately after a line's final token if that token is
<code>return</code>
</li>
<li>one of the <a href="#Operators_and_punctuation">operators and punctuation</a>
<li>one of the <a href="#Operators_and_Delimiters">operators and delimiters</a>
<code>++</code>,
<code>--</code>,
<code>)</code>,
@@ -254,11 +254,10 @@ const fallthrough if range type
continue for import return var
</pre>
<h3 id="Operators_and_punctuation">Operators and punctuation</h3>
<h3 id="Operators_and_Delimiters">Operators and Delimiters</h3>
<p>
The following character sequences represent <a href="#Operators">operators</a>
(including <a href="#assign_op">assignment operators</a>) and punctuation:
The following character sequences represent <a href="#Operators">operators</a>, delimiters, and other special tokens:
</p>
<pre class="grammar">
+ &amp; += &amp;= &amp;&amp; == != ( )
@@ -686,9 +685,11 @@ If a variable has not yet been assigned a value, its value is the
<h2 id="Types">Types</h2>
<p>
A type determines a set of values together with operations and methods specific
to those values. A type may be denoted by a <i>type name</i>, if it has one,
or specified using a <i>type literal</i>, which composes a type from existing types.
A type determines the set of values and operations specific to values of that
type. Types may be <i>named</i> or <i>unnamed</i>. Named types are specified
by a (possibly <a href="#Qualified_identifiers">qualified</a>)
<a href="#Type_declarations"><i>type name</i></a>; unnamed types are specified
using a <i>type literal</i>, which composes a new type from existing types.
</p>
<pre class="ebnf">
@@ -701,7 +702,6 @@ TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType
<p>
Named instances of the boolean, numeric, and string types are
<a href="#Predeclared_identifiers">predeclared</a>.
Other named types are introduced with <a href="#Type_declarations">type declarations</a>.
<i>Composite types</i>&mdash;array, struct, pointer, function,
interface, slice, map, and channel types&mdash;may be constructed using
type literals.
@@ -717,23 +717,16 @@ is the underlying type of the type to which <code>T</code> refers in its
</p>
<pre>
type (
A1 = string
A2 = A1
)
type (
B1 string
B2 B1
B3 []B1
B4 B3
)
type T1 string
type T2 T1
type T3 []T1
type T4 T3
</pre>
<p>
The underlying type of <code>string</code>, <code>A1</code>, <code>A2</code>, <code>B1</code>,
and <code>B2</code> is <code>string</code>.
The underlying type of <code>[]B1</code>, <code>B3</code>, and <code>B4</code> is <code>[]B1</code>.
The underlying type of <code>string</code>, <code>T1</code>, and <code>T2</code>
is <code>string</code>. The underlying type of <code>[]T1</code>, <code>T3</code>,
and <code>T4</code> is <code>[]T1</code>.
</p>
<h3 id="Method_sets">Method sets</h3>
@@ -745,7 +738,7 @@ The method set of any other type <code>T</code> consists of all
The method set of the corresponding <a href="#Pointer_types">pointer type</a> <code>*T</code>
is the set of all methods declared with receiver <code>*T</code> or <code>T</code>
(that is, it also contains the method set of <code>T</code>).
Further rules apply to structs containing embedded fields, as described
Further rules apply to structs containing anonymous fields, as described
in the section on <a href="#Struct_types">struct types</a>.
Any other type has an empty method set.
In a method set, each method must have a
@@ -954,16 +947,16 @@ Moreover, the inner slices must be initialized individually.
<p>
A struct is a sequence of named elements, called fields, each of which has a
name and a type. Field names may be specified explicitly (IdentifierList) or
implicitly (EmbeddedField).
implicitly (AnonymousField).
Within a struct, non-<a href="#Blank_identifier">blank</a> field names must
be <a href="#Uniqueness_of_identifiers">unique</a>.
</p>
<pre class="ebnf">
StructType = "struct" "{" { FieldDecl ";" } "}" .
FieldDecl = (IdentifierList Type | EmbeddedField) [ Tag ] .
EmbeddedField = [ "*" ] TypeName .
Tag = string_lit .
StructType = "struct" "{" { FieldDecl ";" } "}" .
FieldDecl = (IdentifierList Type | AnonymousField) [ Tag ] .
AnonymousField = [ "*" ] TypeName .
Tag = string_lit .
</pre>
<pre>
@@ -981,15 +974,16 @@ struct {
</pre>
<p>
A field declared with a type but no explicit field name is called an <i>embedded field</i>.
An embedded field must be specified as
A field declared with a type but no explicit field name is an <i>anonymous field</i>,
also called an <i>embedded</i> field or an embedding of the type in the struct.
An embedded type must be specified as
a type name <code>T</code> or as a pointer to a non-interface type name <code>*T</code>,
and <code>T</code> itself may not be
a pointer type. The unqualified type name acts as the field name.
</p>
<pre>
// A struct with four embedded fields of types T1, *T2, P.T3 and *P.T4
// A struct with four anonymous fields of type T1, *T2, P.T3 and *P.T4
struct {
T1 // field name is T1
*T2 // field name is T2
@@ -1006,15 +1000,15 @@ in a struct type:
<pre>
struct {
T // conflicts with embedded field *T and *P.T
*T // conflicts with embedded field T and *P.T
*P.T // conflicts with embedded field T and *T
T // conflicts with anonymous field *T and *P.T
*T // conflicts with anonymous field T and *P.T
*P.T // conflicts with anonymous field T and *T
}
</pre>
<p>
A field or <a href="#Method_declarations">method</a> <code>f</code> of an
embedded field in a struct <code>x</code> is called <i>promoted</i> if
anonymous field in a struct <code>x</code> is called <i>promoted</i> if
<code>x.f</code> is a legal <a href="#Selectors">selector</a> that denotes
that field or method <code>f</code>.
</p>
@@ -1031,7 +1025,7 @@ promoted methods are included in the method set of the struct as follows:
</p>
<ul>
<li>
If <code>S</code> contains an embedded field <code>T</code>,
If <code>S</code> contains an anonymous field <code>T</code>,
the <a href="#Method_sets">method sets</a> of <code>S</code>
and <code>*S</code> both include promoted methods with receiver
<code>T</code>. The method set of <code>*S</code> also
@@ -1039,7 +1033,7 @@ promoted methods are included in the method set of the struct as follows:
</li>
<li>
If <code>S</code> contains an embedded field <code>*T</code>,
If <code>S</code> contains an anonymous field <code>*T</code>,
the method sets of <code>S</code> and <code>*S</code> both
include promoted methods with receiver <code>T</code> or
<code>*T</code>.
@@ -1424,10 +1418,11 @@ Two types are either <i>identical</i> or <i>different</i>.
</p>
<p>
A <a href="#Type_definitions">defined type</a> is always different from any other type.
Otherwise, two types are identical if their <a href="#Types">underlying</a> type literals are
structurally equivalent; that is, they have the same literal structure and corresponding
components have identical types. In detail:
Two <a href="#Types">named types</a> are identical if their type names originate in the same
<a href="#Type_declarations">TypeSpec</a>.
A named and an <a href="#Types">unnamed type</a> are always different. Two unnamed types are identical
if the corresponding type literals are identical, that is, if they have the same
literal structure and corresponding components have identical types. In detail:
</p>
<ul>
@@ -1439,8 +1434,8 @@ components have identical types. In detail:
<li>Two struct types are identical if they have the same sequence of fields,
and if corresponding fields have the same names, and identical types,
and identical tags.
<a href="#Exported_identifiers">Non-exported</a> field names from different
packages are always different.</li>
Two anonymous fields are considered to have the same name. Lower-case field
names from different packages are always different.</li>
<li>Two pointer types are identical if they have identical base types.</li>
@@ -1450,9 +1445,8 @@ components have identical types. In detail:
Parameter and result names are not required to match.</li>
<li>Two interface types are identical if they have the same set of methods
with the same names and identical function types.
<a href="#Exported_identifiers">Non-exported</a> method names from different
packages are always different. The order of the methods is irrelevant.</li>
with the same names and identical function types. Lower-case method names from
different packages are always different. The order of the methods is irrelevant.</li>
<li>Two map types are identical if they have identical key and value types.</li>
@@ -1466,24 +1460,13 @@ Given the declarations
<pre>
type (
A0 = []string
A1 = A0
A2 = struct{ a, b int }
A3 = int
A4 = func(A3, float64) *A0
A5 = func(x int, _ float64) *[]string
T0 []string
T1 []string
T2 struct{ a, b int }
T3 struct{ a, c int }
T4 func(int, float64) *T0
T5 func(x int, y float64) *[]string
)
type (
B0 A0
B1 []string
B2 struct{ a, b int }
B3 struct{ a, c int }
B4 func(int, float64) *B0
B5 func(x int, y float64) *A1
)
type C0 = B0
</pre>
<p>
@@ -1491,22 +1474,17 @@ these types are identical:
</p>
<pre>
A0, A1, and []string
A2 and struct{ a, b int }
A3 and int
A4, func(int, float64) *[]string, and A5
B0, B0, and C0
T0 and T0
[]int and []int
struct{ a, b *T5 } and struct{ a, b *T5 }
func(x int, y float64) *[]string, func(int, float64) (result *[]string), and A5
func(x int, y float64) *[]string and func(int, float64) (result *[]string)
</pre>
<p>
<code>B0</code> and <code>B1</code> are different because they are new types
created by distinct <a href="#Type_definitions">type definitions</a>;
<code>func(int, float64) *B0</code> and <code>func(x int, y float64) *[]string</code>
are different because <code>B0</code> is different from <code>[]string</code>.
<code>T0</code> and <code>T1</code> are different because they are named types
with distinct declarations; <code>func(int, float64) *T0</code> and
<code>func(x int, y float64) *[]string</code> are different because <code>T0</code>
is different from <code>[]string</code>.
</p>
@@ -1524,7 +1502,7 @@ A value <code>x</code> is <i>assignable</i> to a <a href="#Variables">variable</
<li>
<code>x</code>'s type <code>V</code> and <code>T</code> have identical
<a href="#Types">underlying types</a> and at least one of <code>V</code>
or <code>T</code> is not a <a href="#Type_definitions">defined</a> type.
or <code>T</code> is not a <a href="#Types">named type</a>.
</li>
<li>
<code>T</code> is an interface type and
@@ -1533,7 +1511,7 @@ or <code>T</code> is not a <a href="#Type_definitions">defined</a> type.
<li>
<code>x</code> is a bidirectional channel value, <code>T</code> is a channel type,
<code>x</code>'s type <code>V</code> and <code>T</code> have identical element types,
and at least one of <code>V</code> or <code>T</code> is not a defined type.
and at least one of <code>V</code> or <code>T</code> is not a named type.
</li>
<li>
<code>x</code> is the predeclared identifier <code>nil</code> and <code>T</code>
@@ -1862,60 +1840,23 @@ last non-empty expression list.
<h3 id="Type_declarations">Type declarations</h3>
<p>
A type declaration binds an identifier, the <i>type name</i>, to a <a href="#Types">type</a>.
Type declarations come in two forms: alias declarations and type definitions.
<p>
<pre class="ebnf">
TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .
TypeSpec = AliasDecl | TypeDef .
</pre>
<h4 id="Alias_declarations">Alias declarations</h4>
<p>
An alias declaration binds an identifier to the given type.
A type declaration binds an identifier, the <i>type name</i>, to a new type
that has the same <a href="#Types">underlying type</a> as an existing type,
and operations defined for the existing type are also defined for the new type.
The new type is <a href="#Type_identity">different</a> from the existing type.
</p>
<pre class="ebnf">
AliasDecl = identifier "=" Type .
TypeDecl = "type" ( TypeSpec | "(" { TypeSpec ";" } ")" ) .
TypeSpec = identifier Type .
</pre>
<p>
Within the <a href="#Declarations_and_scope">scope</a> of
the identifier, it serves as an <i>alias</i> for the type.
</p>
<pre>
type IntArray [16]int
type (
nodeList = []*Node // nodeList and []*Node are identical types
Polar = polar // Polar and polar denote identical types
)
</pre>
<h4 id="Type_definitions">Type definitions</h4>
<p>
A type definition creates a new, distinct type with the same
<a href="#Types">underlying type</a> and operations as the given type,
and binds an identifier to it.
</p>
<pre class="ebnf">
TypeDef = identifier Type .
</pre>
<p>
The new type is called a <i>defined type</i>.
It is <a href="#Type_identity">different</a> from any other type,
including the type it is created from.
</p>
<pre>
type (
Point struct{ x, y float64 } // Point and struct{ x, y float64 } are different types
polar Point // polar and Point denote different types
Point struct{ x, y float64 }
Polar Point
)
type TreeNode struct {
@@ -1931,9 +1872,8 @@ type Block interface {
</pre>
<p>
A defined type may have <a href="#Method_declarations">methods</a> associated with it.
It does not inherit any methods bound to the given type,
but the <a href="#Method_sets">method set</a>
The declared type does not inherit any <a href="#Method_declarations">methods</a>
bound to the existing type, but the <a href="#Method_sets">method set</a>
of an interface type or of elements of a composite type remains unchanged:
</p>
@@ -1951,7 +1891,7 @@ type NewMutex Mutex
type PtrMutex *Mutex
// The method set of *PrintableMutex contains the methods
// Lock and Unlock bound to its embedded field Mutex.
// Lock and Unlock bound to its anonymous field Mutex.
type PrintableMutex struct {
Mutex
}
@@ -1961,8 +1901,8 @@ type MyBlock Block
</pre>
<p>
Type definitions may be used to define different boolean, numeric,
or string types and associate methods with them:
A type declaration may be used to define a different boolean, numeric, or string
type and attach methods to it:
</p>
<pre>
@@ -1984,8 +1924,8 @@ func (tz TimeZone) String() string {
<h3 id="Variable_declarations">Variable declarations</h3>
<p>
A variable declaration creates one or more <a href="#Variables">variables</a>,
binds corresponding identifiers to them, and gives each a type and an initial value.
A variable declaration creates one or more variables, binds corresponding
identifiers to them, and gives each a type and an initial value.
</p>
<pre class="ebnf">
@@ -2143,8 +2083,8 @@ and associates the method with the receiver's <i>base type</i>.
</p>
<pre class="ebnf">
MethodDecl = "func" Receiver MethodName ( Function | Signature ) .
Receiver = Parameters .
MethodDecl = "func" Receiver MethodName ( Function | Signature ) .
Receiver = Parameters .
</pre>
<p>
@@ -2153,7 +2093,7 @@ name. That parameter section must declare a single non-variadic parameter, the r
Its type must be of the form <code>T</code> or <code>*T</code> (possibly using
parentheses) where <code>T</code> is a type name. The type denoted by <code>T</code> is called
the receiver <i>base type</i>; it must not be a pointer or interface type and
it must be <a href="#Type_definitions">defined</a> in the same package as the method.
it must be declared in the same package as the method.
The method is said to be <i>bound</i> to the base type and the method name
is visible only within <a href="#Selectors">selectors</a> for type <code>T</code>
or <code>*T</code>.
@@ -2295,8 +2235,7 @@ The key is interpreted as a field name for struct literals,
an index for array and slice literals, and a key for map literals.
For map literals, all elements must have a key. It is an error
to specify multiple elements with the same field name or
constant key value. For non-constant map keys, see the section on
<a href="#Order_of_evaluation">evaluation order</a>.
constant key value.
</p>
<p>
@@ -2553,13 +2492,13 @@ If <code>x</code> is a package name, see the section on
A selector <code>f</code> may denote a field or method <code>f</code> of
a type <code>T</code>, or it may refer
to a field or method <code>f</code> of a nested
<a href="#Struct_types">embedded field</a> of <code>T</code>.
The number of embedded fields traversed
<a href="#Struct_types">anonymous field</a> of <code>T</code>.
The number of anonymous fields traversed
to reach <code>f</code> is called its <i>depth</i> in <code>T</code>.
The depth of a field or method <code>f</code>
declared in <code>T</code> is zero.
The depth of a field or method <code>f</code> declared in
an embedded field <code>A</code> in <code>T</code> is the
an anonymous field <code>A</code> in <code>T</code> is the
depth of <code>f</code> in <code>A</code> plus one.
</p>
@@ -3384,7 +3323,7 @@ to the type of the other operand.
<p>
The right operand in a shift expression must have unsigned integer type
or be an untyped constant representable by a value of type <code>uint</code>.
or be an untyped constant that can be converted to unsigned integer type.
If the left operand of a non-constant shift expression is an untyped constant,
it is first converted to the type it would assume if the shift expression were
replaced by its left operand alone.
@@ -3582,33 +3521,6 @@ IEEE-754 standard; whether a <a href="#Run_time_panics">run-time panic</a>
occurs is implementation-specific.
</p>
<p>
An implementation may combine multiple floating-point operations into a single
fused operation, possibly across statements, and produce a result that differs
from the value obtained by executing and rounding the instructions individually.
A floating-point type <a href="#Conversions">conversion</a> explicitly rounds to
the precision of the target type, preventing fusion that would discard that rounding.
</p>
<p>
For instance, some architectures provide a "fused multiply and add" (FMA) instruction
that computes <code>x*y + z</code> without rounding the intermediate result <code>x*y</code>.
These examples show when a Go implementation can use that instruction:
</p>
<pre>
// FMA allowed for computing r, because x*y is not explicitly rounded:
r = x*y + z
r = z; r += x*y
t = x*y; r = t + z
*p = x*y; r = *p + z
r = x*y + float64(z)
// FMA disallowed for computing r, because it would omit rounding of x*y:
r = float64(x*y) + z
r = z; r += float64(x*y)
t = float64(x*y); r = t + z
</pre>
<h4 id="String_concatenation">String concatenation</h4>
@@ -3667,7 +3579,7 @@ These terms and the result of the comparisons are defined as follows:
</li>
<li>
Floating-point values are comparable and ordered,
Floating point values are comparable and ordered,
as defined by the IEEE-754 standard.
</li>
@@ -3937,8 +3849,7 @@ in any of these cases:
</li>
<li>
ignoring struct tags (see below),
<code>x</code>'s type and <code>T</code> are pointer types
that are not <a href="#Type_definitions">defined types</a>,
<code>x</code>'s type and <code>T</code> are unnamed pointer types
and their pointer base types have identical underlying types.
</li>
<li>
@@ -4523,8 +4434,8 @@ a[i] = 23
<p>
An <i>assignment operation</i> <code>x</code> <i>op</i><code>=</code>
<code>y</code> where <i>op</i> is a binary <a href="#Arithmetic_operators">arithmetic operator</a>
is equivalent to <code>x</code> <code>=</code> <code>x</code> <i>op</i>
<code>y</code> where <i>op</i> is a binary arithmetic operation is equivalent
to <code>x</code> <code>=</code> <code>x</code> <i>op</i>
<code>(y)</code> but evaluates <code>x</code>
only once. The <i>op</i><code>=</code> construct is a single token.
In assignment operations, both the left- and right-hand expression lists
@@ -5126,7 +5037,7 @@ function completes.
<pre>
go Server()
go func(ch chan&lt;- bool) { for { sleep(10); ch &lt;- true }} (c)
go func(ch chan&lt;- bool) { for { sleep(10); ch &lt;- true; }} (c)
</pre>
@@ -5672,7 +5583,7 @@ make(T, n) slice slice of type T with length n and capacity n
make(T, n, m) slice slice of type T with length n and capacity m
make(T) map map of type T
make(T, n) map map of type T with initial space for approximately n elements
make(T, n) map map of type T with initial space for n elements
make(T) channel unbuffered channel of type T
make(T, n) channel buffered channel of type T, buffer size n
@@ -5695,15 +5606,9 @@ s := make([]int, 1e3) // slice with len(s) == cap(s) == 1000
s := make([]int, 1&lt;&lt;63) // illegal: len(s) is not representable by a value of type int
s := make([]int, 10, 0) // illegal: len(s) > cap(s)
c := make(chan int, 10) // channel with a buffer size of 10
m := make(map[string]int, 100) // map with initial space for approximately 100 elements
m := make(map[string]int, 100) // map with initial space for 100 elements
</pre>
<p>
Calling <code>make</code> with a map type and size hint <code>n</code> will
create a map with initial space to hold <code>n</code> map elements.
The precise behavior is implementation-dependent.
</p>
<h3 id="Appending_and_copying_slices">Appending to and copying slices</h3>
@@ -5965,11 +5870,6 @@ print prints all arguments; formatting of arguments is implementation-speci
println like print but prints spaces between arguments and a newline at the end
</pre>
<p>
Implementation restriction: <code>print</code> and <code>println</code> need not
accept arbitrary argument types, but printing of boolean, numeric, and string
<a href="#Types">types</a> must be supported.
</p>
<h2 id="Packages">Packages</h2>
@@ -6431,7 +6331,7 @@ func Sizeof(variable ArbitraryType) uintptr
A <code>Pointer</code> is a <a href="#Pointer_types">pointer type</a> but a <code>Pointer</code>
value may not be <a href="#Address_operators">dereferenced</a>.
Any pointer or value of <a href="#Types">underlying type</a> <code>uintptr</code> can be converted to
a type of underlying type <code>Pointer</code> and vice versa.
a <code>Pointer</code> type and vice versa.
The effect of converting between <code>Pointer</code> and <code>uintptr</code> is implementation-defined.
</p>
@@ -6509,7 +6409,7 @@ The following minimal alignment properties are guaranteed:
</li>
<li>For a variable <code>x</code> of array type: <code>unsafe.Alignof(x)</code> is the same as
the alignment of a variable of the array's element type.
<code>unsafe.Alignof(x[0])</code>, but at least 1.
</li>
</ol>

View File

@@ -59,12 +59,6 @@ The <a href="https://reddit.com/r/golang">golang sub-Reddit</a> is a place
for Go news and discussion.
</p>
<h3 id="gotime"><a href="https://changelog.com/gotime">Go Time Podcast</a></h3>
<p>
The <a href="https://changelog.com/gotime">Go Time podcast</a> is a panel of Go experts and special guests
discussing the Go programming language, the community, and everything in between.
</p>
<h2 id="community">Community resources</h2>
<h3 id="go_user_groups"><a href="/wiki/GoUserGroups">Go User Groups</a></h3>

View File

@@ -143,13 +143,10 @@ packaged Go distribution.
<p>
To build a bootstrap tool chain from source, use
either the git branch <code>release-branch.go1.4</code> or
<a href="https://storage.googleapis.com/golang/go1.4-bootstrap-20170531.tar.gz">go1.4-bootstrap-20170531.tar.gz</a>,
<a href="https://storage.googleapis.com/golang/go1.4-bootstrap-20161024.tar.gz">go1.4-bootstrap-20161024.tar.gz</a>,
which contains the Go 1.4 source code plus accumulated fixes
to keep the tools running on newer operating systems.
(Go 1.4 was the last distribution in which the tool chain was written in C.)
After unpacking the Go 1.4 source, <code>cd</code> to
the <code>src</code> subdirectory and run <code>make.bash</code> (or,
on Windows, <code>make.bat</code>).
</p>
<p>
@@ -221,7 +218,7 @@ To build without <code>cgo</code>, set the environment variable
Change to the directory that will be its parent
and make sure the <code>go</code> directory does not exist.
Then clone the repository and check out the latest release tag
(<code class="versionTag">go1.8.1</code>, for example):</p>
(<code class="versionTag">go1.7.4</code>, for example):</p>
<pre>
$ git clone https://go.googlesource.com/go
@@ -409,7 +406,7 @@ New releases are announced on the
<a href="//groups.google.com/group/golang-announce">golang-announce</a>
mailing list.
Each announcement mentions the latest release tag, for instance,
<code class="versionTag">go1.8.1</code>.
<code class="versionTag">go1.7.4</code>.
</p>
<p>

View File

@@ -222,7 +222,8 @@ and building a simple program, as follows.
Create your <a href="code.html#Workspaces">workspace</a> directory,
<code class="testUnix">$HOME/go</code><code class="testWindows">%USERPROFILE%\go</code>.
(If you'd like to use a different directory,
you will need to <a href="https://golang.org/wiki/SettingGOPATH">set the <code>GOPATH</code> environment variable</a>.)
you will need to set the <code>GOPATH</code> environment variable;
see <a href="code.html#Workspaces">How to Write Go Code</a> for details.)
</p>
<p>
@@ -249,7 +250,7 @@ $ <b>cd $HOME/go/src/hello</b>
$ <b>go build</b>
</pre>
<pre class="testWindows">
<pre class="testWindows" style="display: none">
C:\&gt; <b>cd %USERPROFILE%\go\src\hello</b>
C:\Users\Gopher\go\src\hello&gt; <b>go build</b>
</pre>
@@ -266,7 +267,7 @@ $ <b>./hello</b>
hello, world
</pre>
<pre class="testWindows">
<pre class="testWindows" style="display: none">
C:\Users\Gopher\go\src\hello&gt; <b>hello</b>
hello, world
</pre>

View File

@@ -20,7 +20,7 @@ This mail is delivered to a small security team.
Your email will be acknowledged within 24 hours, and you'll receive a more
detailed response to your email within 72 hours indicating the next steps in
handling your report.
For critical problems, you can encrypt your report using our PGP key (listed below).
If you would like, you can encrypt your report using our PGP key (listed below).
</p>
<p>
@@ -118,12 +118,6 @@ If you have any suggestions to improve this policy, please send an email to
<h3>PGP Key for <a href="mailto:security@golang.org">security@golang.org</a></h3>
<p>
We accept PGP-encrypted email, but the majority of the security team
are not regular PGP users so it's somewhat inconvenient. Please only
use PGP for critical security reports.
</p>
<pre>
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: GPGTools - https://gpgtools.org

View File

@@ -8,8 +8,8 @@
# Consult http://www.iana.org/time-zones for the latest versions.
# Versions to use.
CODE=2017b
DATA=2017b
CODE=2016j
DATA=2016j
set -e
rm -rf work
@@ -42,7 +42,7 @@ zip -0 -r ../../zoneinfo.zip *
cd ../..
echo
if [ "$1" = "-work" ]; then
if [ "$1" == "-work" ]; then
echo Left workspace behind in work/.
else
rm -rf work

Binary file not shown.

View File

@@ -24,16 +24,7 @@ func run(args ...string) string {
buf := new(bytes.Buffer)
cmd := exec.Command("adb", args...)
cmd.Stdout = io.MultiWriter(os.Stdout, buf)
// If the adb subprocess somehow hangs, go test will kill this wrapper
// and wait for our os.Stderr (and os.Stdout) to close as a result.
// However, if the os.Stderr (or os.Stdout) file descriptors are
// passed on, the hanging adb subprocess will hold them open and
// go test will hang forever.
//
// Avoid that by wrapping stderr, breaking the short circuit and
// forcing cmd.Run to use another pipe and goroutine to pass
// along stderr from adb.
cmd.Stderr = struct{ io.Writer }{os.Stderr}
cmd.Stderr = os.Stderr
log.Printf("adb %s", strings.Join(args, " "))
err := cmd.Run()
if err != nil {

View File

@@ -1,18 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Issue 18452: show pos info in undefined name errors
package p
import (
"C"
"fmt"
)
func a() {
fmt.Println("Hello, world!")
C.function_that_does_not_exist() // line 16
C.pi // line 17
}

View File

@@ -1,7 +0,0 @@
package main
import "C"
func main() {
_ = C.malloc // ERROR HERE
}

View File

@@ -17,7 +17,7 @@ check() {
expect() {
file=$1
shift
if go build -gcflags=-C $file >errs 2>&1; then
if go build $file >errs 2>&1; then
echo 1>&2 misc/cgo/errors/test.bash: BUG: expected cgo to fail on $file but it succeeded
exit 1
fi
@@ -47,8 +47,6 @@ expect issue13635.go C.uchar C.schar C.ushort C.uint C.ulong C.longlong C.ulongl
check issue13830.go
check issue16116.go
check issue16591.go
check issue18889.go
expect issue18452.go issue18452.go:16 issue18452.go:17
if ! go build issue14669.go; then
exit 1

View File

@@ -12,7 +12,7 @@ FC=$1
goos=$(go env GOOS)
libext="so"
if [ "$goos" = "darwin" ]; then
if [ "$goos" == "darwin" ]; then
libext="dylib"
fi

View File

@@ -76,8 +76,5 @@ func TestThreadLock(t *testing.T) { testThreadLockFunc(t) }
func TestCheckConst(t *testing.T) { testCheckConst(t) }
func Test17537(t *testing.T) { test17537(t) }
func Test18126(t *testing.T) { test18126(t) }
func Test20369(t *testing.T) { test20369(t) }
func Test18720(t *testing.T) { test18720(t) }
func Test20266(t *testing.T) { test20266(t) }
func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) }

View File

@@ -73,7 +73,7 @@ func test18146(t *testing.T) {
}
runtime.GOMAXPROCS(threads)
argv := append(os.Args, "-test.run=NoSuchTestExists")
if err := syscall.Exec(os.Args[0], argv, os.Environ()); err != nil {
if err := syscall.Exec(os.Args[0], argv, nil); err != nil {
t.Fatal(err)
}
}

View File

@@ -1,28 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cgotest
/*
#define HELLO "hello"
#define WORLD "world"
#define HELLO_WORLD HELLO "\000" WORLD
struct foo { char c; };
#define SIZE_OF(x) sizeof(x)
#define SIZE_OF_FOO SIZE_OF(struct foo)
*/
import "C"
import "testing"
func test18720(t *testing.T) {
if C.HELLO_WORLD != "hello\000world" {
t.Fatalf(`expected "hello\000world", but got %q`, C.HELLO_WORLD)
}
// Issue 20125.
if got, want := C.SIZE_OF_FOO, 1; got != want {
t.Errorf("C.SIZE_OF_FOO == %v, expected %v", got, want)
}
}

View File

@@ -1,21 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Issue 20266: use -I with a relative path.
package cgotest
/*
#cgo CFLAGS: -I issue20266 -Iissue20266 -Ddef20266
#include "issue20266.h"
*/
import "C"
import "testing"
func test20266(t *testing.T) {
if got, want := C.issue20266, 20266; got != want {
t.Errorf("got %d, want %d", got, want)
}
}

View File

@@ -1,9 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#define issue20266 20266
#ifndef def20266
#error "expected def20266 to be defined"
#endif

View File

@@ -1,20 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cgotest
/*
#define UINT64_MAX 18446744073709551615ULL
*/
import "C"
import (
"math"
"testing"
)
func test20369(t *testing.T) {
if C.UINT64_MAX != math.MaxUint64 {
t.Fatalf("got %v, want %v", uint64(C.UINT64_MAX), uint64(math.MaxUint64))
}
}

View File

@@ -74,15 +74,18 @@ func testNaming(t *testing.T) {
}
}
if c := C.myfloat_def; c != 1.5 {
t.Errorf("C.myint_def = %v, want 1.5", c)
}
{
const c = C.myfloat_def
if c != 1.5 {
t.Errorf("C.myint as const = %v, want 1.5", c)
// This would be nice, but it has never worked.
/*
if c := C.myfloat_def; c != 1.5 {
t.Errorf("C.myint_def = %v, want 1.5", c)
}
}
{
const c = C.myfloat_def
if c != 1.5 {
t.Errorf("C.myint as const = %v, want 1.5", c)
}
}
*/
if s := C.mystring_def; s != "hello" {
t.Errorf("C.mystring_def = %q, want %q", s, "hello")

View File

@@ -17,7 +17,7 @@ package cgotest
static stack_t oss;
static char signalStack[SIGSTKSZ];
static void changeSignalStack(void) {
static void changeSignalStack() {
stack_t ss;
memset(&ss, 0, sizeof ss);
ss.ss_sp = signalStack;
@@ -29,7 +29,7 @@ static void changeSignalStack(void) {
}
}
static void restoreSignalStack(void) {
static void restoreSignalStack() {
#if (defined(__x86_64__) || defined(__i386__)) && defined(__APPLE__)
// The Darwin C library enforces a minimum that the kernel does not.
// This is OK since we allocated this much space in mpreinit,
@@ -42,7 +42,7 @@ static void restoreSignalStack(void) {
}
}
static int zero(void) {
static int zero() {
return 0;
}
*/

View File

@@ -115,10 +115,8 @@ func init() {
func goEnv(key string) string {
out, err := exec.Command("go", "env", key).Output()
if err != nil {
fmt.Fprintf(os.Stderr, "go env %s failed:\n%s\n", key, err)
if ee, ok := err.(*exec.ExitError); ok {
fmt.Fprintf(os.Stderr, "%s", ee.Stderr)
}
fmt.Fprintf(os.Stderr, "go env %s failed:\n%s", key, err)
fmt.Fprintf(os.Stderr, "%s", err.(*exec.ExitError).Stderr)
os.Exit(2)
}
return strings.TrimSpace(string(out))
@@ -220,7 +218,15 @@ func TestEarlySignalHandler(t *testing.T) {
}
func TestSignalForwarding(t *testing.T) {
checkSignalForwardingTest(t)
switch GOOS {
case "darwin":
switch GOARCH {
case "arm", "arm64":
t.Skipf("skipping on %s/%s; see https://golang.org/issue/13701", GOOS, GOARCH)
}
case "windows":
t.Skip("skipping signal test on Windows")
}
defer func() {
os.Remove("libgo2.a")
@@ -245,19 +251,32 @@ func TestSignalForwarding(t *testing.T) {
cmd = exec.Command(bin[0], append(bin[1:], "1")...)
out, err := cmd.CombinedOutput()
t.Logf("%s", out)
expectSignal(t, err, syscall.SIGSEGV)
// Test SIGPIPE forwarding
cmd = exec.Command(bin[0], append(bin[1:], "3")...)
out, err = cmd.CombinedOutput()
t.Logf("%s", out)
expectSignal(t, err, syscall.SIGPIPE)
if err == nil {
t.Logf("%s", out)
t.Error("test program succeeded unexpectedly")
} else if ee, ok := err.(*exec.ExitError); !ok {
t.Logf("%s", out)
t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err)
} else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
t.Logf("%s", out)
t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys())
} else if !ws.Signaled() || ws.Signal() != syscall.SIGSEGV {
t.Logf("%s", out)
t.Errorf("got %v; expected SIGSEGV", ee)
}
}
func TestSignalForwardingExternal(t *testing.T) {
checkSignalForwardingTest(t)
switch GOOS {
case "darwin":
switch GOARCH {
case "arm", "arm64":
t.Skipf("skipping on %s/%s; see https://golang.org/issue/13701", GOOS, GOARCH)
}
case "windows":
t.Skip("skipping signal test on Windows")
}
defer func() {
os.Remove("libgo2.a")
@@ -325,7 +344,14 @@ func TestSignalForwardingExternal(t *testing.T) {
continue
}
if expectSignal(t, err, syscall.SIGSEGV) {
if ee, ok := err.(*exec.ExitError); !ok {
t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err)
} else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys())
} else if !ws.Signaled() || ws.Signal() != syscall.SIGSEGV {
t.Errorf("got %v; expected SIGSEGV", ee)
} else {
// We got the error we expected.
return
}
}
@@ -333,38 +359,6 @@ func TestSignalForwardingExternal(t *testing.T) {
t.Errorf("program succeeded unexpectedly %d times", tries)
}
// checkSignalForwardingTest calls t.Skip if the SignalForwarding test
// doesn't work on this platform.
func checkSignalForwardingTest(t *testing.T) {
switch GOOS {
case "darwin":
switch GOARCH {
case "arm", "arm64":
t.Skipf("skipping on %s/%s; see https://golang.org/issue/13701", GOOS, GOARCH)
}
case "windows":
t.Skip("skipping signal test on Windows")
}
}
// expectSignal checks that err, the exit status of a test program,
// shows a failure due to a specific signal. Returns whether we found
// the expected signal.
func expectSignal(t *testing.T, err error, sig syscall.Signal) bool {
if err == nil {
t.Error("test program succeeded unexpectedly")
} else if ee, ok := err.(*exec.ExitError); !ok {
t.Errorf("error (%v) has type %T; expected exec.ExitError", err, err)
} else if ws, ok := ee.Sys().(syscall.WaitStatus); !ok {
t.Errorf("error.Sys (%v) has type %T; expected syscall.WaitStatus", ee.Sys(), ee.Sys())
} else if !ws.Signaled() || ws.Signal() != sig {
t.Errorf("got %v; expected signal %v", ee, sig)
} else {
return true
}
return false
}
func TestOsSignal(t *testing.T) {
switch GOOS {
case "windows":
@@ -544,79 +538,3 @@ func hasDynTag(t *testing.T, f *elf.File, tag elf.DynTag) bool {
}
return false
}
func TestSIGPROF(t *testing.T) {
switch GOOS {
case "windows", "plan9":
t.Skipf("skipping SIGPROF test on %s", GOOS)
}
t.Parallel()
defer func() {
os.Remove("testp6" + exeSuffix)
os.Remove("libgo6.a")
os.Remove("libgo6.h")
}()
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-o", "libgo6.a", "libgo6")
cmd.Env = gopathEnv
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}
ccArgs := append(cc, "-o", "testp6"+exeSuffix, "main6.c", "libgo6.a")
if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}
argv := cmdToRun("./testp6")
cmd = exec.Command(argv[0], argv[1:]...)
if out, err := cmd.CombinedOutput(); err != nil {
t.Logf("%s", out)
t.Fatal(err)
}
}
// TestCompileWithoutShared tests that if we compile code without the
// -shared option, we can put it into an archive. When we use the go
// tool with -buildmode=c-archive, it passes -shared to the compiler,
// so we override that. The go tool doesn't work this way, but Bazel
// will likely do it in the future. And it ought to work. This test
// was added because at one time it did not work on PPC GNU/Linux.
func TestCompileWithoutShared(t *testing.T) {
// For simplicity, reuse the signal forwarding test.
checkSignalForwardingTest(t)
defer func() {
os.Remove("libgo2.a")
os.Remove("libgo2.h")
}()
cmd := exec.Command("go", "build", "-buildmode=c-archive", "-gcflags=-shared=false", "-o", "libgo2.a", "libgo2")
cmd.Env = gopathEnv
t.Log(cmd.Args)
out, err := cmd.CombinedOutput()
t.Logf("%s", out)
if err != nil {
t.Fatal(err)
}
exe := "./testnoshared" + exeSuffix
ccArgs := append(cc, "-o", exe, "main5.c", "libgo2.a")
t.Log(ccArgs)
out, err = exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput()
t.Logf("%s", out)
if err != nil {
t.Fatal(err)
}
defer os.Remove(exe)
binArgs := append(cmdToRun(exe), "3")
t.Log(binArgs)
out, err = exec.Command(binArgs[0], binArgs[1:]...).CombinedOutput()
t.Logf("%s", out)
expectSignal(t, err, syscall.SIGPIPE)
}

View File

@@ -17,7 +17,6 @@
#include <unistd.h>
#include <sched.h>
#include <time.h>
#include <errno.h>
#include "libgo2.h"
@@ -27,7 +26,6 @@ static void die(const char* msg) {
}
static volatile sig_atomic_t sigioSeen;
static volatile sig_atomic_t sigpipeSeen;
// Use up some stack space.
static void recur(int i, char *p) {
@@ -39,10 +37,6 @@ static void recur(int i, char *p) {
}
}
static void pipeHandler(int signo, siginfo_t* info, void* ctxt) {
sigpipeSeen = 1;
}
// Signal handler that uses up more stack space than a goroutine will have.
static void ioHandler(int signo, siginfo_t* info, void* ctxt) {
char a[1024];
@@ -112,10 +106,6 @@ static void init() {
die("sigaction");
}
sa.sa_sigaction = pipeHandler;
if (sigaction(SIGPIPE, &sa, NULL) < 0) {
die("sigaction");
}
}
int main(int argc, char** argv) {
@@ -177,30 +167,7 @@ int main(int argc, char** argv) {
nanosleep(&ts, NULL);
i++;
if (i > 5000) {
fprintf(stderr, "looping too long waiting for SIGIO\n");
exit(EXIT_FAILURE);
}
}
if (verbose) {
printf("provoking SIGPIPE\n");
}
GoRaiseSIGPIPE();
if (verbose) {
printf("waiting for sigpipeSeen\n");
}
// Wait until the signal has been delivered.
i = 0;
while (!sigpipeSeen) {
ts.tv_sec = 0;
ts.tv_nsec = 1000000;
nanosleep(&ts, NULL);
i++;
if (i > 5000) {
fprintf(stderr, "looping too long waiting for SIGPIPE\n");
fprintf(stderr, "looping too long waiting for signal\n");
exit(EXIT_FAILURE);
}
}

View File

@@ -11,7 +11,6 @@
#include <string.h>
#include <time.h>
#include <sched.h>
#include <unistd.h>
#include "libgo3.h"
@@ -26,31 +25,6 @@ static void ioHandler(int signo, siginfo_t* info, void* ctxt) {
sigioSeen = 1;
}
// Set up the SIGPIPE signal handler in a high priority constructor, so
// that it is installed before the Go code starts.
static void pipeHandler(int signo, siginfo_t* info, void* ctxt) {
const char *s = "unexpected SIGPIPE\n";
write(2, s, strlen(s));
exit(EXIT_FAILURE);
}
static void init(void) __attribute__ ((constructor (200)));
static void init() {
struct sigaction sa;
memset(&sa, 0, sizeof sa);
sa.sa_sigaction = pipeHandler;
if (sigemptyset(&sa.sa_mask) < 0) {
die("sigemptyset");
}
sa.sa_flags = SA_SIGINFO;
if (sigaction(SIGPIPE, &sa, NULL) < 0) {
die("sigaction");
}
}
int main(int argc, char** argv) {
int verbose;
struct sigaction sa;
@@ -60,14 +34,6 @@ int main(int argc, char** argv) {
verbose = argc > 2;
setvbuf(stdout, NULL, _IONBF, 0);
if (verbose) {
printf("raising SIGPIPE\n");
}
// Test that the Go runtime handles SIGPIPE, even if we installed
// a non-default SIGPIPE handler before the runtime initializes.
ProvokeSIGPIPE();
if (verbose) {
printf("calling sigaction\n");
}

View File

@@ -68,24 +68,6 @@ int main(int argc, char** argv) {
break;
}
case 3: {
if (verbose) {
printf("attempting SIGPIPE\n");
}
int fd[2];
if (pipe(fd) != 0) {
printf("pipe(2) failed\n");
return 0;
}
// Close the reading end.
close(fd[0]);
// Expect that write(2) fails (EPIPE)
if (write(fd[1], "some data", 9) != -1) {
printf("write(2) unexpectedly succeeded\n");
return 0;
}
}
default:
printf("Unknown test: %d\n", test);
return 0;

View File

@@ -1,34 +0,0 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test that using the Go profiler in a C program does not crash.
#include <stddef.h>
#include <sys/time.h>
#include "libgo6.h"
int main(int argc, char **argv) {
struct timeval tvstart, tvnow;
int diff;
gettimeofday(&tvstart, NULL);
go_start_profile();
// Busy wait so we have something to profile.
// If we just sleep the profiling signal will never fire.
while (1) {
gettimeofday(&tvnow, NULL);
diff = (tvnow.tv_sec - tvstart.tv_sec) * 1000 * 1000 + (tvnow.tv_usec - tvstart.tv_usec);
// Profile frequency is 100Hz so we should definitely
// get a signal in 50 milliseconds.
if (diff > 50 * 1000)
break;
}
go_stop_profile();
return 0;
}

View File

@@ -4,30 +4,6 @@
package main
/*
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
// Raise SIGPIPE.
static void CRaiseSIGPIPE() {
int fds[2];
if (pipe(fds) == -1) {
perror("pipe");
exit(EXIT_FAILURE);
}
// Close the reader end
close(fds[0]);
// Write to the writer end to provoke a SIGPIPE
if (write(fds[1], "some data", 9) != -1) {
fprintf(stderr, "write to a closed pipe succeeded\n");
exit(EXIT_FAILURE);
}
close(fds[1]);
}
*/
import "C"
import (
@@ -70,11 +46,5 @@ func TestSEGV() {
func Noop() {
}
// Raise SIGPIPE.
//export GoRaiseSIGPIPE
func GoRaiseSIGPIPE() {
C.CRaiseSIGPIPE()
}
func main() {
}

View File

@@ -40,17 +40,5 @@ func SawSIGIO() C.int {
}
}
// ProvokeSIGPIPE provokes a kernel-initiated SIGPIPE.
//export ProvokeSIGPIPE
func ProvokeSIGPIPE() {
r, w, err := os.Pipe()
if err != nil {
panic(err)
}
r.Close()
defer w.Close()
w.Write([]byte("some data"))
}
func main() {
}

View File

@@ -1,25 +0,0 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"io/ioutil"
"runtime/pprof"
)
import "C"
//export go_start_profile
func go_start_profile() {
pprof.StartCPUProfile(ioutil.Discard)
}
//export go_stop_profile
func go_stop_profile() {
pprof.StopCPUProfile()
}
func main() {
}

View File

@@ -12,7 +12,6 @@
// int8_t DidInitRun();
// int8_t DidMainRun();
// int32_t FromPkg();
// uint32_t Divu(uint32_t, uint32_t);
int main(void) {
int8_t ran_init = DidInitRun();
if (!ran_init) {
@@ -31,11 +30,6 @@ int main(void) {
fprintf(stderr, "ERROR: FromPkg=%d, want %d\n", from_pkg, 1024);
return 1;
}
uint32_t divu = Divu(2264, 31);
if (divu != 73) {
fprintf(stderr, "ERROR: Divu(2264, 31)=%d, want %d\n", divu, 73);
return 1;
}
// test.bash looks for "PASS" to ensure this program has reached the end.
printf("PASS\n");
return 0;

View File

@@ -8,5 +8,3 @@ import "C"
//export FromPkg
func FromPkg() int32 { return 1024 }
//export Divu
func Divu(a, b uint32) uint32 { return a / b }

View File

@@ -27,7 +27,7 @@ fi
# Directory where cgo headers and outputs will be installed.
# The installation directory format varies depending on the platform.
installdir=pkg/${goos}_${goarch}_testcshared_shared
if [ "${goos}" = "darwin" ]; then
if [ "${goos}" == "darwin" ]; then
installdir=pkg/${goos}_${goarch}_testcshared
fi
@@ -40,13 +40,13 @@ function cleanup() {
rm -f testp testp2 testp3 testp4 testp5
rm -rf pkg "${goroot}/${installdir}"
if [ "$goos" = "android" ]; then
if [ "$goos" == "android" ]; then
adb shell rm -rf "$androidpath"
fi
}
trap cleanup EXIT
if [ "$goos" = "android" ]; then
if [ "$goos" == "android" ]; then
adb shell mkdir -p "$androidpath"
fi
@@ -69,7 +69,7 @@ function run() {
function binpush() {
bin=${1}
if [ "$goos" = "android" ]; then
if [ "$goos" == "android" ]; then
adb push "$bin" "${androidpath}/${bin}" 2>/dev/null
fi
}
@@ -79,7 +79,7 @@ rm -rf pkg
suffix="-installsuffix testcshared"
libext="so"
if [ "$goos" = "darwin" ]; then
if [ "$goos" == "darwin" ]; then
libext="dylib"
fi
@@ -89,7 +89,7 @@ GOPATH=$(pwd) go install -buildmode=c-shared $suffix libgo
GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo.$libext src/libgo/libgo.go
binpush libgo.$libext
if [ "$goos" = "linux" ] || [ "$goos" = "android" ] ; then
if [ "$goos" == "linux" ] || [ "$goos" == "android" ] ; then
if readelf -d libgo.$libext | grep TEXTREL >/dev/null; then
echo "libgo.$libext has TEXTREL set"
exit 1
@@ -97,8 +97,8 @@ if [ "$goos" = "linux" ] || [ "$goos" = "android" ] ; then
fi
GOGCCFLAGS=$(go env GOGCCFLAGS)
if [ "$goos" = "android" ]; then
GOGCCFLAGS="${GOGCCFLAGS} -pie -fuse-ld=gold"
if [ "$goos" == "android" ]; then
GOGCCFLAGS="${GOGCCFLAGS} -pie"
fi
status=0
@@ -127,7 +127,7 @@ fi
GOPATH=$(pwd) go build -buildmode=c-shared $suffix -o libgo2.$libext libgo2
binpush libgo2.$libext
linkflags="-Wl,--no-as-needed"
if [ "$goos" = "darwin" ]; then
if [ "$goos" == "darwin" ]; then
linkflags=""
fi
$(go env CC) ${GOGCCFLAGS} -o testp2 main2.c $linkflags libgo2.$libext
@@ -139,7 +139,7 @@ if [ "$output" != "PASS" ]; then
fi
# test3: tests main.main is exported on android.
if [ "$goos" = "android" ]; then
if [ "$goos" == "android" ]; then
$(go env CC) ${GOGCCFLAGS} -o testp3 main3.c -ldl
binpush testp3
output=$(run ./testp ./libgo.so)
@@ -179,13 +179,6 @@ if test "$output" != "PASS"; then
status=1
fi
if test "$libext" = "dylib"; then
# make sure dylibs are well-formed
if ! otool -l libgo*.dylib >/dev/null; then
status=1
fi
fi
if test $status = 0; then
echo "ok"
fi

View File

@@ -1,46 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"iface_i"
"log"
"plugin"
)
func main() {
a, err := plugin.Open("iface_a.so")
if err != nil {
log.Fatalf(`plugin.Open("iface_a.so"): %v`, err)
}
b, err := plugin.Open("iface_b.so")
if err != nil {
log.Fatalf(`plugin.Open("iface_b.so"): %v`, err)
}
af, err := a.Lookup("F")
if err != nil {
log.Fatalf(`a.Lookup("F") failed: %v`, err)
}
bf, err := b.Lookup("F")
if err != nil {
log.Fatalf(`b.Lookup("F") failed: %v`, err)
}
if af.(func() interface{})() != bf.(func() interface{})() {
panic("empty interfaces not equal")
}
ag, err := a.Lookup("G")
if err != nil {
log.Fatalf(`a.Lookup("G") failed: %v`, err)
}
bg, err := b.Lookup("G")
if err != nil {
log.Fatalf(`b.Lookup("G") failed: %v`, err)
}
if ag.(func() iface_i.I)() != bg.(func() iface_i.I)() {
panic("nonempty interfaces not equal")
}
}

View File

@@ -1,17 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "iface_i"
//go:noinline
func F() interface{} {
return (*iface_i.T)(nil)
}
//go:noinline
func G() iface_i.I {
return (*iface_i.T)(nil)
}

View File

@@ -1,17 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "iface_i"
//go:noinline
func F() interface{} {
return (*iface_i.T)(nil)
}
//go:noinline
func G() iface_i.I {
return (*iface_i.T)(nil)
}

View File

@@ -1,17 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package iface_i
type I interface {
M()
}
type T struct {
}
func (t *T) M() {
}
// *T implements I

View File

@@ -1,13 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dynamodbstreamsevt
import "encoding/json"
var foo json.RawMessage
type Event struct{}
func (e *Event) Dummy() {}

View File

@@ -1,31 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The bug happened like this:
// 1) The main binary adds an itab for *json.UnsupportedValueError / error
// (concrete type / interface type). This itab goes in hash bucket 0x111.
// 2) The plugin adds that same itab again. That makes a cycle in the itab
// chain rooted at hash bucket 0x111.
// 3) The main binary then asks for the itab for *dynamodbstreamsevt.Event /
// json.Unmarshaler. This itab happens to also live in bucket 0x111.
// The lookup code goes into an infinite loop searching for this itab.
// The code is carefully crafted so that the two itabs are both from the
// same bucket, and so that the second itab doesn't exist in
// the itab hashmap yet (so the entire linked list must be searched).
package main
import (
"encoding/json"
"issue18676/dynamodbstreamsevt"
"plugin"
)
func main() {
plugin.Open("plugin.so")
var x interface{} = (*dynamodbstreamsevt.Event)(nil)
if _, ok := x.(json.Unmarshaler); !ok {
println("something")
}
}

View File

@@ -1,11 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "C"
import "issue18676/dynamodbstreamsevt"
func F(evt *dynamodbstreamsevt.Event) {}

View File

@@ -1,23 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "plugin"
func main() {
p, err := plugin.Open("plugin.so")
if err != nil {
panic(err)
}
sym, err := p.Lookup("Foo")
if err != nil {
panic(err)
}
f := sym.(func() int)
if f() != 42 {
panic("expected f() == 42")
}
}

View File

@@ -1,9 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
func Foo() int {
return 42
}

View File

@@ -15,8 +15,8 @@ goos=$(go env GOOS)
goarch=$(go env GOARCH)
function cleanup() {
rm -f plugin*.so unnamed*.so iface*.so
rm -rf host pkg sub iface issue18676 issue19534
rm -f plugin*.so unnamed*.so
rm -rf host pkg sub
}
trap cleanup EXIT
@@ -32,21 +32,3 @@ GOPATH=$(pwd) go build -buildmode=plugin unnamed2.go
GOPATH=$(pwd) go build host
LD_LIBRARY_PATH=$(pwd) ./host
# Test that types and itabs get properly uniqified.
GOPATH=$(pwd) go build -buildmode=plugin iface_a
GOPATH=$(pwd) go build -buildmode=plugin iface_b
GOPATH=$(pwd) go build iface
LD_LIBRARY_PATH=$(pwd) ./iface
# Test for issue 18676 - make sure we don't add the same itab twice.
# The buggy code hangs forever, so use a timeout to check for that.
GOPATH=$(pwd) go build -buildmode=plugin -o plugin.so src/issue18676/plugin.go
GOPATH=$(pwd) go build -o issue18676 src/issue18676/main.go
timeout 10s ./issue18676
# Test for issue 19534 - that we can load a plugin built in a path with non-alpha
# characters
GOPATH=$(pwd) go build -buildmode=plugin -ldflags='-pluginpath=issue.19534' -o plugin.so src/issue19534/plugin.go
GOPATH=$(pwd) go build -o issue19534 src/issue19534/main.go
./issue19534

View File

@@ -9,15 +9,4 @@ import "C"
func FuncInt() int { return 1 }
// Add a recursive type to to check that type equality across plugins doesn't
// crash. See https://golang.org/issues/19258
func FuncRecursive() X { return X{} }
type Y struct {
X *X
}
type X struct {
Y Y
}
func main() {}

View File

@@ -9,13 +9,4 @@ import "C"
func FuncInt() int { return 2 }
func FuncRecursive() X { return X{} }
type Y struct {
X *X
}
type X struct {
Y Y
}
func main() {}

View File

@@ -1,12 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This program segfaulted during libpreinit when built with -msan:
// http://golang.org/issue/18707
package main
import "C"
func main() {}

View File

@@ -68,25 +68,6 @@ fi
status=0
testmsanshared() {
goos=$(go env GOOS)
suffix="-installsuffix testsanitizers"
libext="so"
if [ "$goos" = "darwin" ]; then
libext="dylib"
fi
go build -msan -buildmode=c-shared $suffix -o ${TMPDIR}/libmsanshared.$libext msan_shared.go
echo 'int main() { return 0; }' > ${TMPDIR}/testmsanshared.c
$CC $(go env GOGCCFLAGS) -fsanitize=memory -o ${TMPDIR}/testmsanshared ${TMPDIR}/testmsanshared.c ${TMPDIR}/libmsanshared.$libext
if ! LD_LIBRARY_PATH=. ${TMPDIR}/testmsanshared; then
echo "FAIL: msan_shared"
status=1
fi
rm -f ${TMPDIR}/{testmsanshared,testmsanshared.c,libmsanshared.$libext}
}
if test "$msan" = "yes"; then
if ! go build -msan std; then
echo "FAIL: build -msan std"
@@ -127,29 +108,8 @@ if test "$msan" = "yes"; then
echo "FAIL: msan_fail"
status=1
fi
testmsanshared
fi
testtsanshared() {
goos=$(go env GOOS)
suffix="-installsuffix tsan"
libext="so"
if [ "$goos" = "darwin" ]; then
libext="dylib"
fi
go build -buildmode=c-shared $suffix -o ${TMPDIR}/libtsanshared.$libext tsan_shared.go
echo 'int main() { return 0; }' > ${TMPDIR}/testtsanshared.c
$CC $(go env GOGCCFLAGS) -fsanitize=thread -o ${TMPDIR}/testtsanshared ${TMPDIR}/testtsanshared.c ${TMPDIR}/libtsanshared.$libext
if ! LD_LIBRARY_PATH=. ${TMPDIR}/testtsanshared; then
echo "FAIL: tsan_shared"
status=1
fi
rm -f ${TMPDIR}/{testtsanshared,testtsanshared.c,libtsanshared.$libext}
}
if test "$tsan" = "yes"; then
echo 'int main() { return 0; }' > ${TMPDIR}/testsanitizers$$.c
ok=yes
@@ -209,14 +169,14 @@ if test "$tsan" = "yes"; then
fi
if test "$ok" = "true"; then
# These tests require rebuilding os/user with -fsanitize=thread.
# This test requires rebuilding os/user with -fsanitize=thread.
testtsan tsan5.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan6.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan7.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan10.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsan tsan11.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
testtsanshared
# This test requires rebuilding runtime/cgo with -fsanitize=thread.
testtsan tsan6.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
# This test requires rebuilding runtime/cgo with -fsanitize=thread.
testtsan tsan7.go "CGO_CFLAGS=-fsanitize=thread CGO_LDFLAGS=-fsanitize=thread" "-installsuffix=tsan"
fi
fi

View File

@@ -1,31 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
// This program hung when run under the C/C++ ThreadSanitizer.
// TSAN defers asynchronous signals until the signaled thread calls into libc.
// Since the Go runtime makes direct futex syscalls, Go runtime threads could
// run for an arbitrarily long time without triggering the libc interceptors.
// See https://golang.org/issue/18717.
import (
"os"
"os/signal"
"syscall"
)
/*
#cgo CFLAGS: -g -fsanitize=thread
#cgo LDFLAGS: -g -fsanitize=thread
*/
import "C"
func main() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGUSR1)
defer signal.Stop(c)
syscall.Kill(syscall.Getpid(), syscall.SIGUSR1)
<-c
}

View File

@@ -1,55 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
// This program hung when run under the C/C++ ThreadSanitizer. TSAN defers
// asynchronous signals until the signaled thread calls into libc. The runtime's
// sysmon goroutine idles itself using direct usleep syscalls, so it could
// run for an arbitrarily long time without triggering the libc interceptors.
// See https://golang.org/issue/18717.
import (
"os"
"os/signal"
"syscall"
)
/*
#cgo CFLAGS: -g -fsanitize=thread
#cgo LDFLAGS: -g -fsanitize=thread
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void raise_usr2(int signo) {
raise(SIGUSR2);
}
static void register_handler(int signo) {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_ONSTACK;
sa.sa_handler = raise_usr2;
if (sigaction(SIGUSR1, &sa, NULL) != 0) {
perror("failed to register SIGUSR1 handler");
exit(EXIT_FAILURE);
}
}
*/
import "C"
func main() {
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGUSR2)
C.register_handler(C.int(syscall.SIGUSR1))
syscall.Kill(syscall.Getpid(), syscall.SIGUSR1)
<-ch
}

View File

@@ -1,63 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
// This program failed with SIGSEGV when run under the C/C++ ThreadSanitizer.
// The Go runtime had re-registered the C handler with the wrong flags due to a
// typo, resulting in null pointers being passed for the info and context
// parameters to the handler.
/*
#cgo CFLAGS: -fsanitize=thread
#cgo LDFLAGS: -fsanitize=thread
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ucontext.h>
void check_params(int signo, siginfo_t *info, void *context) {
ucontext_t* uc = (ucontext_t*)(context);
if (info->si_signo != signo) {
fprintf(stderr, "info->si_signo does not match signo.\n");
abort();
}
if (uc->uc_stack.ss_size == 0) {
fprintf(stderr, "uc_stack has size 0.\n");
abort();
}
}
// Set up the signal handler in a high priority constructor, so
// that it is installed before the Go code starts.
static void register_handler(void) __attribute__ ((constructor (200)));
static void register_handler() {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = check_params;
if (sigaction(SIGUSR1, &sa, NULL) != 0) {
perror("failed to register SIGUSR1 handler");
exit(EXIT_FAILURE);
}
}
*/
import "C"
import "syscall"
func init() {
C.raise(C.int(syscall.SIGUSR1))
}
func main() {}

View File

@@ -10,6 +10,7 @@ import (
"debug/elf"
"encoding/binary"
"errors"
"flag"
"fmt"
"go/build"
"io"
@@ -165,6 +166,7 @@ func TestMain(m *testing.M) {
// That won't work if GOBIN is set.
os.Unsetenv("GOBIN")
flag.Parse()
exitCode, err := testMain(m)
if err != nil {
log.Fatal(err)
@@ -400,12 +402,6 @@ func TestTrivialExecutablePIE(t *testing.T) {
AssertHasRPath(t, "./trivial.pie", gorootInstallDir)
}
// Build a division test program and check it runs.
func TestDivisionExecutable(t *testing.T) {
goCmd(t, "install", "-linkshared", "division")
run(t, "division executable", "./bin/division")
}
// Build an executable that uses cgo linked against the shared runtime and check it
// runs.
func TestCgoExecutable(t *testing.T) {
@@ -763,13 +759,6 @@ func appendFile(path, content string) {
}
}
func writeFile(path, content string) {
err := ioutil.WriteFile(path, []byte(content), 0644)
if err != nil {
log.Fatalf("ioutil.WriteFile failed: %v", err)
}
}
func TestABIChecking(t *testing.T) {
goCmd(t, "install", "-buildmode=shared", "-linkshared", "depBase")
goCmd(t, "install", "-linkshared", "exe")
@@ -808,10 +797,9 @@ func TestABIChecking(t *testing.T) {
run(t, "rebuilt exe", "./bin/exe")
// If we make a change which does not break ABI (such as adding an unexported
// function) and rebuild libdepBase.so, exe still works, even if new function
// is in a file by itself.
// function) and rebuild libdepBase.so, exe still works.
resetFileStamps()
writeFile("src/depBase/dep2.go", "package depBase\nfunc noABIBreak() {}\n")
appendFile("src/depBase/dep.go", "func noABIBreak() {}\n")
goCmd(t, "install", "-buildmode=shared", "-linkshared", "depBase")
run(t, "after non-ABI breaking change", "./bin/exe")
}
@@ -827,14 +815,3 @@ func TestImplicitInclusion(t *testing.T) {
goCmd(t, "install", "-linkshared", "implicitcmd")
run(t, "running executable linked against library that contains same package as it", "./bin/implicitcmd")
}
// Tests to make sure that the type fields of empty interfaces and itab
// fields of nonempty interfaces are unique even across modules,
// so that interface equality works correctly.
func TestInterface(t *testing.T) {
goCmd(t, "install", "-buildmode=shared", "-linkshared", "iface_a")
// Note: iface_i gets installed implicitly as a dependency of iface_a.
goCmd(t, "install", "-buildmode=shared", "-linkshared", "iface_b")
goCmd(t, "install", "-linkshared", "iface")
run(t, "running type/itab uniqueness tester", "./bin/iface")
}

View File

@@ -5,8 +5,6 @@ import (
"reflect"
)
var SlicePtr interface{} = &[]int{}
var V int = 1
var HasMask []string = []string{"hi"}

View File

@@ -1,17 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
//go:noinline
func div(x, y uint32) uint32 {
return x / y
}
func main() {
a := div(97, 11)
if a != 8 {
panic("FAIL")
}
}

View File

@@ -19,8 +19,6 @@ func F() *C {
return nil
}
var slicePtr interface{} = &[]int{}
func main() {
defer depBase.ImplementedInAsm()
// This code below causes various go.itab.* symbols to be generated in
@@ -34,11 +32,4 @@ func main() {
if reflect.TypeOf(F).Out(0) != reflect.TypeOf(c) {
panic("bad reflection results, see golang.org/issue/18252")
}
sp := reflect.New(reflect.TypeOf(slicePtr).Elem())
s := sp.Interface()
if reflect.TypeOf(s) != reflect.TypeOf(slicePtr) {
panic("bad reflection results, see golang.org/issue/18729")
}
}

View File

@@ -1,17 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import "iface_a"
import "iface_b"
func main() {
if iface_a.F() != iface_b.F() {
panic("empty interfaces not equal")
}
if iface_a.G() != iface_b.G() {
panic("non-empty interfaces not equal")
}
}

View File

@@ -1,17 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package iface_a
import "iface_i"
//go:noinline
func F() interface{} {
return (*iface_i.T)(nil)
}
//go:noinline
func G() iface_i.I {
return (*iface_i.T)(nil)
}

View File

@@ -1,17 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package iface_b
import "iface_i"
//go:noinline
func F() interface{} {
return (*iface_i.T)(nil)
}
//go:noinline
func G() iface_i.I {
return (*iface_i.T)(nil)
}

View File

@@ -1,17 +0,0 @@
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package iface_i
type I interface {
M()
}
type T struct {
}
func (t *T) M() {
}
// *T implements I

View File

@@ -23,37 +23,28 @@ import (
func main() {
devID := detectDevID()
fmt.Printf("export GOIOS_DEV_ID=%s\n", devID)
udid := detectUDID()
mps := detectMobileProvisionFiles(udid)
if len(mps) == 0 {
fail("did not find mobile provision matching device udid %s", udid)
}
mp := detectMobileProvisionFile(udid)
fmt.Println("Available provisioning profiles below.")
fmt.Println("NOTE: Any existing app on the device with the app id specified by GOIOS_APP_ID")
fmt.Println("will be overwritten when running Go programs.")
for _, mp := range mps {
fmt.Println()
fmt.Printf("export GOIOS_DEV_ID=%s\n", devID)
f, err := ioutil.TempFile("", "go_ios_detect_")
check(err)
fname := f.Name()
defer os.Remove(fname)
f, err := ioutil.TempFile("", "go_ios_detect_")
check(err)
fname := f.Name()
defer os.Remove(fname)
out := output(parseMobileProvision(mp))
_, err = f.Write(out)
check(err)
check(f.Close())
out := combinedOutput(parseMobileProvision(mp))
_, err = f.Write(out)
check(err)
check(f.Close())
appID, err := plistExtract(fname, "Entitlements:application-identifier")
check(err)
fmt.Printf("export GOIOS_APP_ID=%s\n", appID)
appID, err := plistExtract(fname, "ApplicationIdentifierPrefix:0")
check(err)
fmt.Printf("export GOIOS_APP_ID=%s\n", appID)
teamID, err := plistExtract(fname, "Entitlements:com.apple.developer.team-identifier")
check(err)
fmt.Printf("export GOIOS_TEAM_ID=%s\n", teamID)
}
teamID, err := plistExtract(fname, "Entitlements:com.apple.developer.team-identifier")
check(err)
fmt.Printf("export GOIOS_TEAM_ID=%s\n", teamID)
}
func detectDevID() string {
@@ -88,11 +79,10 @@ func detectUDID() []byte {
panic("unreachable")
}
func detectMobileProvisionFiles(udid []byte) []string {
func detectMobileProvisionFile(udid []byte) string {
cmd := exec.Command("mdfind", "-name", ".mobileprovision")
lines := getLines(cmd)
var files []string
for _, line := range lines {
if len(line) == 0 {
continue
@@ -100,11 +90,12 @@ func detectMobileProvisionFiles(udid []byte) []string {
xmlLines := getLines(parseMobileProvision(string(line)))
for _, xmlLine := range xmlLines {
if bytes.Contains(xmlLine, udid) {
files = append(files, string(line))
return string(line)
}
}
}
return files
fail("did not find mobile provision matching device udid %s", udid)
panic("ureachable")
}
func parseMobileProvision(fname string) *exec.Cmd {
@@ -120,12 +111,12 @@ func plistExtract(fname string, path string) ([]byte, error) {
}
func getLines(cmd *exec.Cmd) [][]byte {
out := output(cmd)
out := combinedOutput(cmd)
return bytes.Split(out, []byte("\n"))
}
func output(cmd *exec.Cmd) []byte {
out, err := cmd.Output()
func combinedOutput(cmd *exec.Cmd) []byte {
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println(strings.Join(cmd.Args, "\n"))
fmt.Fprintln(os.Stderr, err)

View File

@@ -45,10 +45,9 @@ var errRetry = errors.New("failed to start test harness (retry attempted)")
var tmpdir string
var (
devID string
appID string
teamID string
bundleID string
devID string
appID string
teamID string
)
// lock is a file lock to serialize iOS runs. It is global to avoid the
@@ -77,13 +76,6 @@ func main() {
// https://developer.apple.com/membercenter/index.action#accountSummary as Team ID.
teamID = getenv("GOIOS_TEAM_ID")
parts := strings.SplitN(appID, ".", 2)
// For compatibility with the old builders, use a fallback bundle ID
bundleID = "golang.gotest"
if len(parts) == 2 {
bundleID = parts[1]
}
var err error
tmpdir, err = ioutil.TempDir("", "go_darwin_arm_exec_")
if err != nil {
@@ -147,22 +139,22 @@ func run(bin string, args []string) (err error) {
return err
}
pkgpath, err := copyLocalData(appdir)
if err != nil {
return err
}
entitlementsPath := filepath.Join(tmpdir, "Entitlements.plist")
if err := ioutil.WriteFile(entitlementsPath, []byte(entitlementsPlist()), 0744); err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(appdir, "Info.plist"), []byte(infoPlist(pkgpath)), 0744); err != nil {
if err := ioutil.WriteFile(filepath.Join(appdir, "Info.plist"), []byte(infoPlist), 0744); err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(appdir, "ResourceRules.plist"), []byte(resourceRules), 0744); err != nil {
return err
}
pkgpath, err := copyLocalData(appdir)
if err != nil {
return err
}
cmd := exec.Command(
"codesign",
"-f",
@@ -244,9 +236,20 @@ func run(bin string, args []string) (err error) {
return nil
}
s.do(`breakpoint set -n getwd`) // in runtime/cgo/gcc_darwin_arm.go
started = true
s.doCmd("run", "stop reason = signal SIGINT", 20*time.Second)
s.doCmd("run", "stop reason = breakpoint", 20*time.Second)
// Move the current working directory into the faux gopath.
if pkgpath != "src" {
s.do(`breakpoint delete 1`)
s.do(`expr char* $mem = (char*)malloc(512)`)
s.do(`expr $mem = (char*)getwd($mem, 512)`)
s.do(`expr $mem = (char*)strcat($mem, "/` + pkgpath + `")`)
s.do(`call (void)chdir($mem)`)
}
startTestsLen := s.out.Len()
fmt.Fprintln(s.in, `process continue`)
@@ -256,9 +259,7 @@ func run(bin string, args []string) (err error) {
return s.out.LastIndex([]byte("\nPASS\n")) > startTestsLen ||
s.out.LastIndex([]byte("\nPASS\r")) > startTestsLen ||
s.out.LastIndex([]byte("\n(lldb) PASS\n")) > startTestsLen ||
s.out.LastIndex([]byte("\n(lldb) PASS\r")) > startTestsLen ||
s.out.LastIndex([]byte("exited with status = 0 (0x00000000) \n")) > startTestsLen ||
s.out.LastIndex([]byte("exited with status = 0 (0x00000000) \r")) > startTestsLen
s.out.LastIndex([]byte("\n(lldb) PASS\r")) > startTestsLen
}
err = s.wait("test completion", passed, opts.timeout)
if passed(s.out) {
@@ -346,7 +347,7 @@ func newSession(appdir string, args []string, opts options) (*lldbSession, error
i2 := s.out.LastIndex([]byte(" connect"))
return i0 > 0 && i1 > 0 && i2 > 0
}
if err := s.wait("lldb start", cond, 15*time.Second); err != nil {
if err := s.wait("lldb start", cond, 10*time.Second); err != nil {
panic(waitPanic{err})
}
return s, nil
@@ -444,7 +445,7 @@ func parseArgs(binArgs []string) (opts options, remainingArgs []string) {
remainingArgs = append(remainingArgs, arg)
}
f := flag.NewFlagSet("", flag.ContinueOnError)
f.DurationVar(&opts.timeout, "test.timeout", 10*time.Minute, "")
f.DurationVar(&opts.timeout, "test.timeout", 0, "")
f.BoolVar(&opts.lldb, "lldb", false, "")
f.Parse(flagArgs)
return opts, remainingArgs
@@ -517,13 +518,13 @@ func copyLocalData(dstbase string) (pkgpath string, err error) {
}
}
// Copy timezone file.
//
// Typical apps have the zoneinfo.zip in the root of their app bundle,
// read by the time package as the working directory at initialization.
// As we move the working directory to the GOROOT pkg directory, we
// install the zoneinfo.zip file in the pkgpath.
if underGoRoot {
// Copy timezone file.
//
// Typical apps have the zoneinfo.zip in the root of their app bundle,
// read by the time package as the working directory at initialization.
// As we move the working directory to the GOROOT pkg directory, we
// install the zoneinfo.zip file in the pkgpath.
err := cp(
filepath.Join(dstbase, pkgpath),
filepath.Join(cwd, "lib", "time", "zoneinfo.zip"),
@@ -531,19 +532,6 @@ func copyLocalData(dstbase string) (pkgpath string, err error) {
if err != nil {
return "", err
}
// Copy src/runtime/textflag.h for (at least) Test386EndToEnd in
// cmd/asm/internal/asm.
runtimePath := filepath.Join(dstbase, "src", "runtime")
if err := os.MkdirAll(runtimePath, 0755); err != nil {
return "", err
}
err = cp(
filepath.Join(runtimePath, "textflag.h"),
filepath.Join(cwd, "src", "runtime", "textflag.h"),
)
if err != nil {
return "", err
}
}
return finalPkgpath, nil
@@ -581,8 +569,7 @@ func subdir() (pkgpath string, underGoRoot bool, err error) {
)
}
func infoPlist(pkgpath string) string {
return `<?xml version="1.0" encoding="UTF-8"?>
const infoPlist = `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
@@ -590,15 +577,13 @@ func infoPlist(pkgpath string) string {
<key>CFBundleSupportedPlatforms</key><array><string>iPhoneOS</string></array>
<key>CFBundleExecutable</key><string>gotest</string>
<key>CFBundleVersion</key><string>1.0</string>
<key>CFBundleIdentifier</key><string>` + bundleID + `</string>
<key>CFBundleIdentifier</key><string>golang.gotest</string>
<key>CFBundleResourceSpecification</key><string>ResourceRules.plist</string>
<key>LSRequiresIPhoneOS</key><true/>
<key>CFBundleDisplayName</key><string>gotest</string>
<key>GoExecWrapperWorkingDirectory</key><string>` + pkgpath + `</string>
</dict>
</plist>
`
}
func entitlementsPlist() string {
return `<?xml version="1.0" encoding="UTF-8"?>
@@ -606,11 +591,11 @@ func entitlementsPlist() string {
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array><string>` + appID + `</string></array>
<array><string>` + appID + `.golang.gotest</string></array>
<key>get-task-allow</key>
<true/>
<key>application-identifier</key>
<string>` + appID + `</string>
<string>` + appID + `.golang.gotest</string>
<key>com.apple.developer.team-identifier</key>
<string>` + teamID + `</string>
</dict>

View File

@@ -37,26 +37,6 @@ go src=..
testdata
+
vendor
github.com
google
pprof
internal
driver
testdata
+
graph
testdata
+
report
testdata
+
profile
testdata
+
ianlancetaylor
demangle
testdata
+
golang.org
x
arch
@@ -162,8 +142,6 @@ go src=..
regexp
testdata
+
runtime
textflag.h
strconv
testdata
+

View File

@@ -158,15 +158,11 @@ func (fi headerFileInfo) Mode() (mode os.FileMode) {
// sysStat, if non-nil, populates h from system-dependent fields of fi.
var sysStat func(fi os.FileInfo, h *Header) error
// Mode constants from the tar spec.
const (
// Mode constants from the USTAR spec:
// See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_06
c_ISUID = 04000 // Set uid
c_ISGID = 02000 // Set gid
c_ISVTX = 01000 // Save text (sticky bit)
// Common Unix mode constants; these are not defined in any common tar standard.
// Header.FileInfo understands these, but FileInfoHeader will never produce these.
c_ISUID = 04000 // Set uid
c_ISGID = 02000 // Set gid
c_ISVTX = 01000 // Save text (sticky bit)
c_ISDIR = 040000 // Directory
c_ISFIFO = 010000 // FIFO
c_ISREG = 0100000 // Regular file
@@ -212,24 +208,30 @@ func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) {
}
switch {
case fm.IsRegular():
h.Mode |= c_ISREG
h.Typeflag = TypeReg
h.Size = fi.Size()
case fi.IsDir():
h.Typeflag = TypeDir
h.Mode |= c_ISDIR
h.Name += "/"
case fm&os.ModeSymlink != 0:
h.Typeflag = TypeSymlink
h.Mode |= c_ISLNK
h.Linkname = link
case fm&os.ModeDevice != 0:
if fm&os.ModeCharDevice != 0 {
h.Mode |= c_ISCHR
h.Typeflag = TypeChar
} else {
h.Mode |= c_ISBLK
h.Typeflag = TypeBlock
}
case fm&os.ModeNamedPipe != 0:
h.Typeflag = TypeFifo
h.Mode |= c_ISFIFO
case fm&os.ModeSocket != 0:
return nil, fmt.Errorf("archive/tar: sockets not supported")
h.Mode |= c_ISSOCK
default:
return nil, fmt.Errorf("archive/tar: unknown file mode %v", fm)
}

View File

@@ -6,11 +6,9 @@ package tar
import (
"bytes"
"internal/testenv"
"io/ioutil"
"os"
"path"
"path/filepath"
"reflect"
"strings"
"testing"
@@ -29,7 +27,7 @@ func TestFileInfoHeader(t *testing.T) {
if g, e := h.Name, "small.txt"; g != e {
t.Errorf("Name = %q; want %q", g, e)
}
if g, e := h.Mode, int64(fi.Mode().Perm()); g != e {
if g, e := h.Mode, int64(fi.Mode().Perm())|c_ISREG; g != e {
t.Errorf("Mode = %#o; want %#o", g, e)
}
if g, e := h.Size, int64(5); g != e {
@@ -57,7 +55,7 @@ func TestFileInfoHeaderDir(t *testing.T) {
t.Errorf("Name = %q; want %q", g, e)
}
// Ignoring c_ISGID for golang.org/issue/4867
if g, e := h.Mode&^c_ISGID, int64(fi.Mode().Perm()); g != e {
if g, e := h.Mode&^c_ISGID, int64(fi.Mode().Perm())|c_ISDIR; g != e {
t.Errorf("Mode = %#o; want %#o", g, e)
}
if g, e := h.Size, int64(0); g != e {
@@ -69,56 +67,40 @@ func TestFileInfoHeaderDir(t *testing.T) {
}
func TestFileInfoHeaderSymlink(t *testing.T) {
testenv.MustHaveSymlink(t)
tmpdir, err := ioutil.TempDir("", "TestFileInfoHeaderSymlink")
h, err := FileInfoHeader(symlink{}, "some-target")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tmpdir)
link := filepath.Join(tmpdir, "link")
target := tmpdir
err = os.Symlink(target, link)
if err != nil {
t.Fatal(err)
}
fi, err := os.Lstat(link)
if err != nil {
t.Fatal(err)
}
h, err := FileInfoHeader(fi, target)
if err != nil {
t.Fatal(err)
}
if g, e := h.Name, fi.Name(); g != e {
if g, e := h.Name, "some-symlink"; g != e {
t.Errorf("Name = %q; want %q", g, e)
}
if g, e := h.Linkname, target; g != e {
if g, e := h.Linkname, "some-target"; g != e {
t.Errorf("Linkname = %q; want %q", g, e)
}
if g, e := h.Typeflag, byte(TypeSymlink); g != e {
t.Errorf("Typeflag = %v; want %v", g, e)
}
}
type symlink struct{}
func (symlink) Name() string { return "some-symlink" }
func (symlink) Size() int64 { return 0 }
func (symlink) Mode() os.FileMode { return os.ModeSymlink }
func (symlink) ModTime() time.Time { return time.Time{} }
func (symlink) IsDir() bool { return false }
func (symlink) Sys() interface{} { return nil }
func TestRoundTrip(t *testing.T) {
data := []byte("some file contents")
var b bytes.Buffer
tw := NewWriter(&b)
hdr := &Header{
Name: "file.txt",
Uid: 1 << 21, // too big for 8 octal digits
Size: int64(len(data)),
// AddDate to strip monotonic clock reading,
// and Round to discard sub-second precision,
// both of which are not included in the tar header
// and would otherwise break the round-trip check
// below.
ModTime: time.Now().AddDate(0, 0, 0).Round(1 * time.Second),
Name: "file.txt",
Uid: 1 << 21, // too big for 8 octal digits
Size: int64(len(data)),
ModTime: time.Now(),
}
// tar only supports second precision.
hdr.ModTime = hdr.ModTime.Add(-time.Duration(hdr.ModTime.Nanosecond()) * time.Nanosecond)
if err := tw.WriteHeader(hdr); err != nil {
t.Fatalf("tw.WriteHeader: %v", err)
}
@@ -157,7 +139,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// regular file.
h: &Header{
Name: "test.txt",
Mode: 0644,
Mode: 0644 | c_ISREG,
Size: 12,
ModTime: time.Unix(1360600916, 0),
Typeflag: TypeReg,
@@ -167,7 +149,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// symbolic link.
h: &Header{
Name: "link.txt",
Mode: 0777,
Mode: 0777 | c_ISLNK,
Size: 0,
ModTime: time.Unix(1360600852, 0),
Typeflag: TypeSymlink,
@@ -177,7 +159,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// character device node.
h: &Header{
Name: "dev/null",
Mode: 0666,
Mode: 0666 | c_ISCHR,
Size: 0,
ModTime: time.Unix(1360578951, 0),
Typeflag: TypeChar,
@@ -187,7 +169,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// block device node.
h: &Header{
Name: "dev/sda",
Mode: 0660,
Mode: 0660 | c_ISBLK,
Size: 0,
ModTime: time.Unix(1360578954, 0),
Typeflag: TypeBlock,
@@ -197,7 +179,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// directory.
h: &Header{
Name: "dir/",
Mode: 0755,
Mode: 0755 | c_ISDIR,
Size: 0,
ModTime: time.Unix(1360601116, 0),
Typeflag: TypeDir,
@@ -207,7 +189,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// fifo node.
h: &Header{
Name: "dev/initctl",
Mode: 0600,
Mode: 0600 | c_ISFIFO,
Size: 0,
ModTime: time.Unix(1360578949, 0),
Typeflag: TypeFifo,
@@ -217,7 +199,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// setuid.
h: &Header{
Name: "bin/su",
Mode: 0755 | c_ISUID,
Mode: 0755 | c_ISREG | c_ISUID,
Size: 23232,
ModTime: time.Unix(1355405093, 0),
Typeflag: TypeReg,
@@ -227,7 +209,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// setguid.
h: &Header{
Name: "group.txt",
Mode: 0750 | c_ISGID,
Mode: 0750 | c_ISREG | c_ISGID,
Size: 0,
ModTime: time.Unix(1360602346, 0),
Typeflag: TypeReg,
@@ -237,7 +219,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// sticky.
h: &Header{
Name: "sticky.txt",
Mode: 0600 | c_ISVTX,
Mode: 0600 | c_ISREG | c_ISVTX,
Size: 7,
ModTime: time.Unix(1360602540, 0),
Typeflag: TypeReg,
@@ -247,7 +229,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// hard link.
h: &Header{
Name: "hard.txt",
Mode: 0644,
Mode: 0644 | c_ISREG,
Size: 0,
Linkname: "file.txt",
ModTime: time.Unix(1360600916, 0),
@@ -258,7 +240,7 @@ func TestHeaderRoundTrip(t *testing.T) {
// More information.
h: &Header{
Name: "info.txt",
Mode: 0600,
Mode: 0600 | c_ISREG,
Size: 0,
Uid: 1000,
Gid: 1000,

View File

@@ -103,46 +103,51 @@ func (r *pooledFlateReader) Close() error {
}
var (
compressors sync.Map // map[uint16]Compressor
decompressors sync.Map // map[uint16]Decompressor
mu sync.RWMutex // guards compressor and decompressor maps
compressors = map[uint16]Compressor{
Store: func(w io.Writer) (io.WriteCloser, error) { return &nopCloser{w}, nil },
Deflate: func(w io.Writer) (io.WriteCloser, error) { return newFlateWriter(w), nil },
}
decompressors = map[uint16]Decompressor{
Store: ioutil.NopCloser,
Deflate: newFlateReader,
}
)
func init() {
compressors.Store(Store, Compressor(func(w io.Writer) (io.WriteCloser, error) { return &nopCloser{w}, nil }))
compressors.Store(Deflate, Compressor(func(w io.Writer) (io.WriteCloser, error) { return newFlateWriter(w), nil }))
decompressors.Store(Store, Decompressor(ioutil.NopCloser))
decompressors.Store(Deflate, Decompressor(newFlateReader))
}
// RegisterDecompressor allows custom decompressors for a specified method ID.
// The common methods Store and Deflate are built in.
func RegisterDecompressor(method uint16, dcomp Decompressor) {
if _, dup := decompressors.LoadOrStore(method, dcomp); dup {
mu.Lock()
defer mu.Unlock()
if _, ok := decompressors[method]; ok {
panic("decompressor already registered")
}
decompressors[method] = dcomp
}
// RegisterCompressor registers custom compressors for a specified method ID.
// The common methods Store and Deflate are built in.
func RegisterCompressor(method uint16, comp Compressor) {
if _, dup := compressors.LoadOrStore(method, comp); dup {
mu.Lock()
defer mu.Unlock()
if _, ok := compressors[method]; ok {
panic("compressor already registered")
}
compressors[method] = comp
}
func compressor(method uint16) Compressor {
ci, ok := compressors.Load(method)
if !ok {
return nil
}
return ci.(Compressor)
mu.RLock()
defer mu.RUnlock()
return compressors[method]
}
func decompressor(method uint16) Decompressor {
di, ok := decompressors.Load(method)
if !ok {
return nil
}
return di.(Decompressor)
mu.RLock()
defer mu.RUnlock()
return decompressors[method]
}

View File

@@ -5,7 +5,7 @@
/*
Package zip provides support for reading and writing ZIP archives.
See: https://www.pkware.com/appnote
See: https://www.pkware.com/documents/casestudies/APPNOTE.TXT
This package does not support disk spanning.

View File

@@ -11,7 +11,6 @@ import (
"hash"
"hash/crc32"
"io"
"unicode/utf8"
)
// TODO(adg): support zip file comments
@@ -202,20 +201,6 @@ func (w *Writer) Create(name string) (io.Writer, error) {
return w.CreateHeader(header)
}
func hasValidUTF8(s string) bool {
n := 0
for _, r := range s {
// By default, ZIP uses CP437, which is only identical to ASCII for the printable characters.
if r < 0x20 || r >= 0x7f {
if !utf8.ValidRune(r) {
return false
}
n++
}
}
return n > 0
}
// CreateHeader adds a file to the zip file using the provided FileHeader
// for the file metadata.
// It returns a Writer to which the file contents should be written.
@@ -236,10 +221,6 @@ func (w *Writer) CreateHeader(fh *FileHeader) (io.Writer, error) {
fh.Flags |= 0x8 // we will write a data descriptor
if hasValidUTF8(fh.Name) || hasValidUTF8(fh.Comment) {
fh.Flags |= 0x800 // filename or comment have valid utf-8 string
}
fh.CreatorVersion = fh.CreatorVersion&0xff00 | zipVersion20 // preserve compatibility byte
fh.ReaderVersion = zipVersion20

View File

@@ -87,69 +87,6 @@ func TestWriter(t *testing.T) {
}
}
func TestWriterUTF8(t *testing.T) {
var utf8Tests = []struct {
name string
comment string
expect uint16
}{
{
name: "hi, hello",
comment: "in the world",
expect: 0x8,
},
{
name: "hi, こんにちわ",
comment: "in the world",
expect: 0x808,
},
{
name: "hi, hello",
comment: "in the 世界",
expect: 0x808,
},
{
name: "hi, こんにちわ",
comment: "in the 世界",
expect: 0x808,
},
}
// write a zip file
buf := new(bytes.Buffer)
w := NewWriter(buf)
for _, test := range utf8Tests {
h := &FileHeader{
Name: test.name,
Comment: test.comment,
Method: Deflate,
}
w, err := w.CreateHeader(h)
if err != nil {
t.Fatal(err)
}
w.Write([]byte{})
}
if err := w.Close(); err != nil {
t.Fatal(err)
}
// read it back
r, err := NewReader(bytes.NewReader(buf.Bytes()), int64(buf.Len()))
if err != nil {
t.Fatal(err)
}
for i, test := range utf8Tests {
got := r.File[i].Flags
t.Logf("name %v, comment %v", test.name, test.comment)
if got != test.expect {
t.Fatalf("Flags: got %v, want %v", got, test.expect)
}
}
}
func TestWriterOffset(t *testing.T) {
largeData := make([]byte, 1<<17)
for i := range largeData {
@@ -244,11 +181,12 @@ func testReadFile(t *testing.T, f *File, wt *WriteTest) {
}
func BenchmarkCompressedZipGarbage(b *testing.B) {
b.ReportAllocs()
var buf bytes.Buffer
bigBuf := bytes.Repeat([]byte("a"), 1<<20)
runOnce := func(buf *bytes.Buffer) {
for i := 0; i <= b.N; i++ {
buf.Reset()
zw := NewWriter(buf)
zw := NewWriter(&buf)
for j := 0; j < 3; j++ {
w, _ := zw.CreateHeader(&FileHeader{
Name: "foo",
@@ -257,19 +195,11 @@ func BenchmarkCompressedZipGarbage(b *testing.B) {
w.Write(bigBuf)
}
zw.Close()
}
b.ReportAllocs()
// Run once and then reset the timer.
// This effectively discards the very large initial flate setup cost,
// as well as the initialization of bigBuf.
runOnce(&bytes.Buffer{})
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
var buf bytes.Buffer
for pb.Next() {
runOnce(&buf)
if i == 0 {
// Reset the timer after the first time through.
// This effectively discards the very large initial flate setup cost,
// as well as the initialization of bigBuf.
b.ResetTimer()
}
})
}
}

View File

@@ -255,7 +255,7 @@ func TestZip64EdgeCase(t *testing.T) {
testZip64DirectoryRecordLength(buf, t)
}
// Tests that we generate a zip64 file if the directory at offset
// Tests that we generate a zip64 file if the the directory at offset
// 0xFFFFFFFF, but not before.
func TestZip64DirectoryOffset(t *testing.T) {
if testing.Short() && race.Enabled {
@@ -681,18 +681,6 @@ func BenchmarkZip64Test(b *testing.B) {
}
}
func BenchmarkZip64TestSizes(b *testing.B) {
for _, size := range []int64{1 << 12, 1 << 20, 1 << 26} {
b.Run(fmt.Sprint(size), func(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
testZip64(b, size)
}
})
})
}
}
func TestSuffixSaver(t *testing.T) {
const keep = 10
ss := &suffixSaver{keep: keep}

View File

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer
// Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer
// object, creating another object (Reader or Writer) that also implements
// the interface but provides buffering and some help for textual I/O.
package bufio
@@ -458,7 +458,6 @@ func (b *Reader) ReadString(delim byte) (string, error) {
}
// WriteTo implements io.WriterTo.
// This may make multiple calls to the Read method of the underlying Reader.
func (b *Reader) WriteTo(w io.Writer) (n int64, err error) {
n, err = b.writeBuf(w)
if err != nil {
@@ -514,7 +513,7 @@ func (b *Reader) writeBuf(w io.Writer) (int64, error) {
// Writer implements buffering for an io.Writer object.
// If an error occurs writing to a Writer, no more data will be
// accepted and all subsequent writes, and Flush, will return the error.
// accepted and all subsequent writes will return the error.
// After all data has been written, the client should call the
// Flush method to guarantee all data has been forwarded to
// the underlying io.Writer.

View File

@@ -169,6 +169,7 @@ func genLine(buf *bytes.Buffer, lineNum, n int, addNewline bool) {
}
buf.WriteByte('\n')
}
return
}
// Test the line splitter, including some carriage returns but no long lines.

View File

@@ -19,70 +19,52 @@ fi
sete=false
if [ "$1" = "-e" ]; then
sete=true
shift
sete=true
shift
fi
if [ "$sete" = true ]; then
set -e
set -e
fi
pattern="$1"
if [ "$pattern" = "" ]; then
pattern=.
pattern=.
fi
./make.bash || exit 1
GOROOT="$(cd .. && pwd)"
gettargets() {
../bin/go tool dist list | sed -e 's|/|-|'
echo linux-386-387
echo linux-arm-arm5
}
selectedtargets() {
gettargets | egrep -v 'android-arm|darwin-arm' | egrep "$pattern"
}
# put linux, nacl first in the target list to get all the architectures up front.
linux_nacl_targets() {
selectedtargets | egrep 'linux|nacl' | sort
}
non_linux_nacl_targets() {
selectedtargets | egrep -v 'linux|nacl' | sort
}
# Note words in $targets are separated by both newlines and spaces.
targets="$(linux_nacl_targets) $(non_linux_nacl_targets)"
targets="$((../bin/go tool dist list | sed -n 's/^\(.*\)\/\(.*\)/\1-\2/p'; echo linux-386-387 linux-arm-arm5) | sort | egrep -v android-arm | egrep "$pattern" | egrep 'linux|nacl')
$(../bin/go tool dist list | sed -n 's/^\(.*\)\/\(.*\)/\1-\2/p' | egrep -v 'android-arm|darwin-arm' | egrep "$pattern" | egrep -v 'linux|nacl')"
failed=false
for target in $targets
do
echo ""
echo "### Building $target"
export GOOS=$(echo $target | sed 's/-.*//')
export GOARCH=$(echo $target | sed 's/.*-//')
unset GO386 GOARM
if [ "$GOARCH" = "arm5" ]; then
export GOARCH=arm
export GOARM=5
fi
if [ "$GOARCH" = "387" ]; then
export GOARCH=386
export GO386=387
fi
if ! "$GOROOT/bin/go" build -a std cmd; then
failed=true
if $sete; then
exit 1
fi
fi
echo ""
echo "### Building $target"
export GOOS=$(echo $target | sed 's/-.*//')
export GOARCH=$(echo $target | sed 's/.*-//')
unset GO386 GOARM
if [ "$GOARCH" = "arm5" ]; then
export GOARCH=arm
export GOARM=5
fi
if [ "$GOARCH" = "387" ]; then
export GOARCH=386
export GO386=387
fi
if ! "$GOROOT/bin/go" build -a std cmd; then
failed=true
if $sete; then
exit 1
fi
fi
done
if [ "$failed" = "true" ]; then
echo "" 1>&2
echo "Build(s) failed." 1>&2
exit 1
echo "" 1>&2
echo "Build(s) failed." 1>&2
exit 1
fi

View File

@@ -85,11 +85,11 @@ type uintptr uintptr
// byte is an alias for uint8 and is equivalent to uint8 in all ways. It is
// used, by convention, to distinguish byte values from 8-bit unsigned
// integer values.
type byte = uint8
type byte byte
// rune is an alias for int32 and is equivalent to int32 in all ways. It is
// used, by convention, to distinguish character values from integer values.
type rune = int32
type rune rune
// iota is a predeclared identifier representing the untyped integer ordinal
// number of the current const specification in a (usually parenthesized)
@@ -179,7 +179,7 @@ func cap(v Type) int
// Channel: The channel's buffer is initialized with the specified
// buffer capacity. If zero, or the size is omitted, the channel is
// unbuffered.
func make(t Type, size ...IntegerType) Type
func make(Type, size IntegerType) Type
// The new built-in function allocates memory. The first argument is a type,
// not a value, and the value returned is a pointer to a newly

View File

@@ -15,15 +15,10 @@ import (
// A Buffer is a variable-sized buffer of bytes with Read and Write methods.
// The zero value for Buffer is an empty buffer ready to use.
type Buffer struct {
buf []byte // contents are the bytes buf[off : len(buf)]
off int // read at &buf[off], write at &buf[len(buf)]
lastRead readOp // last read operation, so that Unread* can work correctly.
// FIXME: lastRead can fit in a single byte
// memory to hold first slice; helps small buffers avoid allocation.
// FIXME: it would be advisable to align Buffer to cachelines to avoid false
// sharing.
bootstrap [64]byte
buf []byte // contents are the bytes buf[off : len(buf)]
off int // read at &buf[off], write at &buf[len(buf)]
bootstrap [64]byte // memory to hold first slice; helps small buffers avoid allocation.
lastRead readOp // last read operation, so that Unread* can work correctly.
}
// The readOp constants describe the last action performed on
@@ -73,13 +68,13 @@ func (b *Buffer) Cap() int { return cap(b.buf) }
// but continues to use the same allocated storage.
// It panics if n is negative or greater than the length of the buffer.
func (b *Buffer) Truncate(n int) {
if n == 0 {
b.Reset()
return
}
b.lastRead = opInvalid
if n < 0 || n > b.Len() {
switch {
case n < 0 || n > b.Len():
panic("bytes.Buffer: truncation out of range")
case n == 0:
// Reuse buffer space.
b.off = 0
}
b.buf = b.buf[0 : b.off+n]
}
@@ -87,22 +82,7 @@ func (b *Buffer) Truncate(n int) {
// Reset resets the buffer to be empty,
// but it retains the underlying storage for use by future writes.
// Reset is the same as Truncate(0).
func (b *Buffer) Reset() {
b.buf = b.buf[:0]
b.off = 0
b.lastRead = opInvalid
}
// tryGrowByReslice is a inlineable version of grow for the fast-case where the
// internal buffer only needs to be resliced.
// It returns the index where bytes should be written and whether it succeeded.
func (b *Buffer) tryGrowByReslice(n int) (int, bool) {
if l := len(b.buf); l+n <= cap(b.buf) {
b.buf = b.buf[:l+n]
return l, true
}
return 0, false
}
func (b *Buffer) Reset() { b.Truncate(0) }
// grow grows the buffer to guarantee space for n more bytes.
// It returns the index where bytes should be written.
@@ -111,33 +91,29 @@ func (b *Buffer) grow(n int) int {
m := b.Len()
// If buffer is empty, reset to recover space.
if m == 0 && b.off != 0 {
b.Reset()
b.Truncate(0)
}
// Try to grow by means of a reslice.
if i, ok := b.tryGrowByReslice(n); ok {
return i
}
// Check if we can make use of bootstrap array.
if b.buf == nil && n <= len(b.bootstrap) {
b.buf = b.bootstrap[:n]
return 0
}
if m+n <= cap(b.buf)/2 {
// We can slide things down instead of allocating a new
// slice. We only need m+n <= cap(b.buf) to slide, but
// we instead let capacity get twice as large so we
// don't spend all our time copying.
copy(b.buf[:], b.buf[b.off:])
} else {
// Not enough space anywhere, we need to allocate.
buf := makeSlice(2*cap(b.buf) + n)
copy(buf, b.buf[b.off:])
if len(b.buf)+n > cap(b.buf) {
var buf []byte
if b.buf == nil && n <= len(b.bootstrap) {
buf = b.bootstrap[0:]
} else if m+n <= cap(b.buf)/2 {
// We can slide things down instead of allocating a new
// slice. We only need m+n <= cap(b.buf) to slide, but
// we instead let capacity get twice as large so we
// don't spend all our time copying.
copy(b.buf[:], b.buf[b.off:])
buf = b.buf[:m]
} else {
// not enough space anywhere
buf = makeSlice(2*cap(b.buf) + n)
copy(buf, b.buf[b.off:])
}
b.buf = buf
b.off = 0
}
// Restore b.off and len(b.buf).
b.off = 0
b.buf = b.buf[:m+n]
return m
b.buf = b.buf[0 : b.off+m+n]
return b.off + m
}
// Grow grows the buffer's capacity, if necessary, to guarantee space for
@@ -158,10 +134,7 @@ func (b *Buffer) Grow(n int) {
// buffer becomes too large, Write will panic with ErrTooLarge.
func (b *Buffer) Write(p []byte) (n int, err error) {
b.lastRead = opInvalid
m, ok := b.tryGrowByReslice(len(p))
if !ok {
m = b.grow(len(p))
}
m := b.grow(len(p))
return copy(b.buf[m:], p), nil
}
@@ -170,10 +143,7 @@ func (b *Buffer) Write(p []byte) (n int, err error) {
// buffer becomes too large, WriteString will panic with ErrTooLarge.
func (b *Buffer) WriteString(s string) (n int, err error) {
b.lastRead = opInvalid
m, ok := b.tryGrowByReslice(len(s))
if !ok {
m = b.grow(len(s))
}
m := b.grow(len(s))
return copy(b.buf[m:], s), nil
}
@@ -191,7 +161,7 @@ func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
b.lastRead = opInvalid
// If buffer is empty, reset to recover space.
if b.off >= len(b.buf) {
b.Reset()
b.Truncate(0)
}
for {
if free := cap(b.buf) - len(b.buf); free < MinRead {
@@ -255,7 +225,7 @@ func (b *Buffer) WriteTo(w io.Writer) (n int64, err error) {
}
}
// Buffer is now empty; reset.
b.Reset()
b.Truncate(0)
return
}
@@ -265,10 +235,7 @@ func (b *Buffer) WriteTo(w io.Writer) (n int64, err error) {
// ErrTooLarge.
func (b *Buffer) WriteByte(c byte) error {
b.lastRead = opInvalid
m, ok := b.tryGrowByReslice(1)
if !ok {
m = b.grow(1)
}
m := b.grow(1)
b.buf[m] = c
return nil
}
@@ -283,10 +250,7 @@ func (b *Buffer) WriteRune(r rune) (n int, err error) {
return 1, nil
}
b.lastRead = opInvalid
m, ok := b.tryGrowByReslice(utf8.UTFMax)
if !ok {
m = b.grow(utf8.UTFMax)
}
m := b.grow(utf8.UTFMax)
n = utf8.EncodeRune(b.buf[m:m+utf8.UTFMax], r)
b.buf = b.buf[:m+n]
return n, nil
@@ -300,7 +264,7 @@ func (b *Buffer) Read(p []byte) (n int, err error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) {
// Buffer is empty, reset to recover space.
b.Reset()
b.Truncate(0)
if len(p) == 0 {
return
}
@@ -338,7 +302,7 @@ func (b *Buffer) ReadByte() (byte, error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) {
// Buffer is empty, reset to recover space.
b.Reset()
b.Truncate(0)
return 0, io.EOF
}
c := b.buf[b.off]
@@ -356,7 +320,7 @@ func (b *Buffer) ReadRune() (r rune, size int, err error) {
b.lastRead = opInvalid
if b.off >= len(b.buf) {
// Buffer is empty, reset to recover space.
b.Reset()
b.Truncate(0)
return 0, 0, io.EOF
}
c := b.buf[b.off]
@@ -373,12 +337,12 @@ func (b *Buffer) ReadRune() (r rune, size int, err error) {
// UnreadRune unreads the last rune returned by ReadRune.
// If the most recent read or write operation on the buffer was
// not a successful ReadRune, UnreadRune returns an error. (In this regard
// not a ReadRune, UnreadRune returns an error. (In this regard
// it is stricter than UnreadByte, which will unread the last byte
// from any read operation.)
func (b *Buffer) UnreadRune() error {
if b.lastRead <= opInvalid {
return errors.New("bytes.Buffer: UnreadRune: previous operation was not a successful ReadRune")
return errors.New("bytes.Buffer: UnreadRune: previous operation was not ReadRune")
}
if b.off >= int(b.lastRead) {
b.off -= int(b.lastRead)
@@ -387,13 +351,12 @@ func (b *Buffer) UnreadRune() error {
return nil
}
// UnreadByte unreads the last byte returned by the most recent successful
// read operation that read at least one byte. If a write has happened since
// the last read, if the last read returned an error, or if the read read zero
// bytes, UnreadByte returns an error.
// UnreadByte unreads the last byte returned by the most recent
// read operation. If write has happened since the last read, UnreadByte
// returns an error.
func (b *Buffer) UnreadByte() error {
if b.lastRead == opInvalid {
return errors.New("bytes.Buffer: UnreadByte: previous operation was not a successful read")
return errors.New("bytes.Buffer: UnreadByte: previous operation was not a read")
}
b.lastRead = opInvalid
if b.off > 0 {
@@ -441,12 +404,10 @@ func (b *Buffer) ReadString(delim byte) (line string, err error) {
return string(slice), err
}
// NewBuffer creates and initializes a new Buffer using buf as its
// initial contents. The new Buffer takes ownership of buf, and the
// caller should not use buf after this call. NewBuffer is intended to
// prepare a Buffer to read existing data. It can also be used to size
// the internal buffer for writing. To do that, buf should have the
// desired capacity but a length of zero.
// NewBuffer creates and initializes a new Buffer using buf as its initial
// contents. It is intended to prepare a Buffer to read existing data. It
// can also be used to size the internal buffer for writing. To do that,
// buf should have the desired capacity but a length of zero.
//
// In most cases, new(Buffer) (or just declaring a Buffer variable) is
// sufficient to initialize a Buffer.

View File

@@ -6,10 +6,8 @@ package bytes_test
import (
. "bytes"
"internal/testenv"
"io"
"math/rand"
"os/exec"
"runtime"
"testing"
"unicode/utf8"
@@ -313,19 +311,6 @@ func TestRuneIO(t *testing.T) {
// Check that UnreadRune works
buf.Reset()
// check at EOF
if err := buf.UnreadRune(); err == nil {
t.Fatal("UnreadRune at EOF: got no error")
}
if _, _, err := buf.ReadRune(); err == nil {
t.Fatal("ReadRune at EOF: got no error")
}
if err := buf.UnreadRune(); err == nil {
t.Fatal("UnreadRune after ReadRune at EOF: got no error")
}
// check not at EOF
buf.Write(b)
for r := rune(0); r < NRune; r++ {
r1, size, _ := buf.ReadRune()
@@ -488,34 +473,15 @@ func TestReadEmptyAtEOF(t *testing.T) {
func TestUnreadByte(t *testing.T) {
b := new(Buffer)
// check at EOF
if err := b.UnreadByte(); err == nil {
t.Fatal("UnreadByte at EOF: got no error")
}
if _, err := b.ReadByte(); err == nil {
t.Fatal("ReadByte at EOF: got no error")
}
if err := b.UnreadByte(); err == nil {
t.Fatal("UnreadByte after ReadByte at EOF: got no error")
}
// check not at EOF
b.WriteString("abcdefghijklmnopqrstuvwxyz")
// after unsuccessful read
if n, err := b.Read(nil); n != 0 || err != nil {
t.Fatalf("Read(nil) = %d,%v; want 0,nil", n, err)
}
if err := b.UnreadByte(); err == nil {
t.Fatal("UnreadByte after Read(nil): got no error")
}
// after successful read
if _, err := b.ReadBytes('m'); err != nil {
_, err := b.ReadBytes('m')
if err != nil {
t.Fatalf("ReadBytes: %v", err)
}
if err := b.UnreadByte(); err != nil {
err = b.UnreadByte()
if err != nil {
t.Fatalf("UnreadByte: %v", err)
}
c, err := b.ReadByte()
@@ -548,38 +514,6 @@ func TestBufferGrowth(t *testing.T) {
}
}
// Test that tryGrowByReslice is inlined.
// Only execute on "linux-amd64" builder in order to avoid breakage.
func TestTryGrowByResliceInlined(t *testing.T) {
targetBuilder := "linux-amd64"
if testenv.Builder() != targetBuilder {
t.Skipf("%q gets executed on %q builder only", t.Name(), targetBuilder)
}
t.Parallel()
goBin := testenv.GoToolPath(t)
out, err := exec.Command(goBin, "tool", "nm", goBin).CombinedOutput()
if err != nil {
t.Fatalf("go tool nm: %v: %s", err, out)
}
// Verify this doesn't exist:
sym := "bytes.(*Buffer).tryGrowByReslice"
if Contains(out, []byte(sym)) {
t.Errorf("found symbol %q in cmd/go, but should be inlined", sym)
}
}
func BenchmarkWriteByte(b *testing.B) {
const n = 4 << 10
b.SetBytes(n)
buf := NewBuffer(make([]byte, n))
for i := 0; i < b.N; i++ {
buf.Reset()
for i := 0; i < n; i++ {
buf.WriteByte('x')
}
}
}
func BenchmarkWriteRune(b *testing.B) {
const n = 4 << 10
const r = '☺'

View File

@@ -46,21 +46,36 @@ func explode(s []byte, n int) [][]byte {
return a[0:na]
}
// countGeneric actually implements Count
func countGeneric(s, sep []byte) int {
// special case
if len(sep) == 0 {
// Count counts the number of non-overlapping instances of sep in s.
// If sep is an empty slice, Count returns 1 + the number of Unicode code points in s.
func Count(s, sep []byte) int {
n := len(sep)
if n == 0 {
return utf8.RuneCount(s) + 1
}
n := 0
for {
i := Index(s, sep)
if i == -1 {
return n
}
n++
s = s[i+len(sep):]
if n > len(s) {
return 0
}
count := 0
c := sep[0]
i := 0
t := s[:len(s)-n+1]
for i < len(t) {
if t[i] != c {
o := IndexByte(t[i:], c)
if o < 0 {
break
}
i += o
}
if n == 1 || Equal(s[i:i+n], sep) {
count++
i += n
continue
}
i++
}
return count
}
// Contains reports whether subslice is within b.
@@ -214,21 +229,20 @@ func genSplit(s, sep []byte, sepSave, n int) [][]byte {
if n < 0 {
n = Count(s, sep) + 1
}
c := sep[0]
start := 0
a := make([][]byte, n)
n--
i := 0
for i < n {
m := Index(s, sep)
if m < 0 {
break
na := 0
for i := 0; i+len(sep) <= len(s) && na+1 < n; i++ {
if s[i] == c && (len(sep) == 1 || Equal(s[i:i+len(sep)], sep)) {
a[na] = s[start : i+sepSave]
na++
start = i + len(sep)
i += len(sep) - 1
}
a[i] = s[:m+sepSave]
s = s[m+len(sep):]
i++
}
a[i] = s
return a[:i+1]
a[na] = s[start:]
return a[0 : na+1]
}
// SplitN slices s into subslices separated by sep and returns a slice of

View File

@@ -4,19 +4,17 @@
package bytes
import "internal/cpu"
//go:noescape
// indexShortStr returns the index of the first instance of c in s, or -1 if c is not present in s.
// indexShortStr requires 2 <= len(c) <= shortStringLen
func indexShortStr(s, c []byte) int // ../runtime/asm_amd64.s
func countByte(s []byte, c byte) int // ../runtime/asm_amd64.s
func indexShortStr(s, c []byte) int // ../runtime/asm_$GOARCH.s
func supportAVX2() bool // ../runtime/asm_$GOARCH.s
var shortStringLen int
func init() {
if cpu.X86.HasAVX2 {
if supportAVX2() {
shortStringLen = 63
} else {
shortStringLen = 31
@@ -96,15 +94,6 @@ func Index(s, sep []byte) int {
return -1
}
// Count counts the number of non-overlapping instances of sep in s.
// If sep is an empty slice, Count returns 1 + the number of Unicode code points in s.
func Count(s, sep []byte) int {
if len(sep) == 1 && cpu.X86.HasPOPCNT {
return countByte(s, sep[0])
}
return countGeneric(s, sep)
}
// primeRK is the prime base used in Rabin-Karp algorithm.
const primeRK = 16777619

View File

@@ -39,9 +39,3 @@ func Index(s, sep []byte) int {
}
return -1
}
// Count counts the number of non-overlapping instances of sep in s.
// If sep is an empty slice, Count returns 1 + the number of Unicode code points in s.
func Count(s, sep []byte) int {
return countGeneric(s, sep)
}

View File

@@ -97,12 +97,6 @@ func Index(s, sep []byte) int {
return -1
}
// Count counts the number of non-overlapping instances of sep in s.
// If sep is an empty slice, Count returns 1 + the number of Unicode code points in s.
func Count(s, sep []byte) int {
return countGeneric(s, sep)
}
// primeRK is the prime base used in Rabin-Karp algorithm.
const primeRK = 16777619

View File

@@ -396,79 +396,6 @@ func TestIndexRune(t *testing.T) {
}
}
// test count of a single byte across page offsets
func TestCountByte(t *testing.T) {
b := make([]byte, 5015) // bigger than a page
windows := []int{1, 2, 3, 4, 15, 16, 17, 31, 32, 33, 63, 64, 65, 128}
testCountWindow := func(i, window int) {
for j := 0; j < window; j++ {
b[i+j] = byte(100)
p := Count(b[i:i+window], []byte{100})
if p != j+1 {
t.Errorf("TestCountByte.Count(%q, 100) = %d", b[i:i+window], p)
}
pGeneric := CountGeneric(b[i:i+window], []byte{100})
if pGeneric != j+1 {
t.Errorf("TestCountByte.CountGeneric(%q, 100) = %d", b[i:i+window], p)
}
}
}
maxWnd := windows[len(windows)-1]
for i := 0; i <= 2*maxWnd; i++ {
for _, window := range windows {
if window > len(b[i:]) {
window = len(b[i:])
}
testCountWindow(i, window)
for j := 0; j < window; j++ {
b[i+j] = byte(0)
}
}
}
for i := 4096 - (maxWnd + 1); i < len(b); i++ {
for _, window := range windows {
if window > len(b[i:]) {
window = len(b[i:])
}
testCountWindow(i, window)
for j := 0; j < window; j++ {
b[i+j] = byte(0)
}
}
}
}
// Make sure we don't count bytes outside our window
func TestCountByteNoMatch(t *testing.T) {
b := make([]byte, 5015)
windows := []int{1, 2, 3, 4, 15, 16, 17, 31, 32, 33, 63, 64, 65, 128}
for i := 0; i <= len(b); i++ {
for _, window := range windows {
if window > len(b[i:]) {
window = len(b[i:])
}
// Fill the window with non-match
for j := 0; j < window; j++ {
b[i+j] = byte(100)
}
// Try to find something that doesn't exist
p := Count(b[i:i+window], []byte{0})
if p != 0 {
t.Errorf("TestCountByteNoMatch(%q, 0) = %d", b[i:i+window], p)
}
pGeneric := CountGeneric(b[i:i+window], []byte{0})
if pGeneric != 0 {
t.Errorf("TestCountByteNoMatch.CountGeneric(%q, 100) = %d", b[i:i+window], p)
}
for j := 0; j < window; j++ {
b[i+j] = byte(0)
}
}
}
}
var bmbuf []byte
func valName(x int) string {
@@ -662,26 +589,6 @@ func BenchmarkCountEasy(b *testing.B) {
})
}
func BenchmarkCountSingle(b *testing.B) {
benchBytes(b, indexSizes, func(b *testing.B, n int) {
buf := bmbuf[0:n]
step := 8
for i := 0; i < len(buf); i += step {
buf[i] = 1
}
expect := (len(buf) + (step - 1)) / step
for i := 0; i < b.N; i++ {
j := Count(buf, []byte{1})
if j != expect {
b.Fatal("bad count", j, expect)
}
}
for i := 0; i < len(buf); i++ {
buf[i] = 0
}
})
}
type ExplodeTest struct {
s string
n int
@@ -1525,59 +1432,6 @@ func BenchmarkTrimSpace(b *testing.B) {
}
}
func makeBenchInputHard() []byte {
tokens := [...]string{
"<a>", "<p>", "<b>", "<strong>",
"</a>", "</p>", "</b>", "</strong>",
"hello", "world",
}
x := make([]byte, 0, 1<<20)
for {
i := rand.Intn(len(tokens))
if len(x)+len(tokens[i]) >= 1<<20 {
break
}
x = append(x, tokens[i]...)
}
return x
}
var benchInputHard = makeBenchInputHard()
func BenchmarkSplitEmptySeparator(b *testing.B) {
for i := 0; i < b.N; i++ {
Split(benchInputHard, nil)
}
}
func BenchmarkSplitSingleByteSeparator(b *testing.B) {
sep := []byte("/")
for i := 0; i < b.N; i++ {
Split(benchInputHard, sep)
}
}
func BenchmarkSplitMultiByteSeparator(b *testing.B) {
sep := []byte("hello")
for i := 0; i < b.N; i++ {
Split(benchInputHard, sep)
}
}
func BenchmarkSplitNSingleByteSeparator(b *testing.B) {
sep := []byte("/")
for i := 0; i < b.N; i++ {
SplitN(benchInputHard, sep, 10)
}
}
func BenchmarkSplitNMultiByteSeparator(b *testing.B) {
sep := []byte("hello")
for i := 0; i < b.N; i++ {
SplitN(benchInputHard, sep, 10)
}
}
func BenchmarkRepeat(b *testing.B) {
for i := 0; i < b.N; i++ {
Repeat([]byte("-"), 80)

View File

@@ -7,4 +7,3 @@ package bytes
// Export func for testing
var IndexBytePortable = indexBytePortable
var EqualPortable = equalPortable
var CountGeneric = countGeneric

View File

@@ -89,25 +89,16 @@ func testAddr2Line(t *testing.T, exepath, addr string) {
func TestAddr2Line(t *testing.T) {
testenv.MustHaveGoBuild(t)
syms := loadSyms(t)
tmpDir, err := ioutil.TempDir("", "TestAddr2Line")
if err != nil {
t.Fatal("TempDir failed: ", err)
}
defer os.RemoveAll(tmpDir)
// Build copy of test binary with debug symbols,
// since the one running now may not have them.
exepath := filepath.Join(tmpDir, "testaddr2line_test.exe")
out, err := exec.Command(testenv.GoToolPath(t), "test", "-c", "-o", exepath, "cmd/addr2line").CombinedOutput()
if err != nil {
t.Fatalf("go test -c -o %v cmd/addr2line: %v\n%s", exepath, err, string(out))
}
os.Args[0] = exepath
syms := loadSyms(t)
exepath = filepath.Join(tmpDir, "testaddr2line.exe")
out, err = exec.Command(testenv.GoToolPath(t), "build", "-o", exepath, "cmd/addr2line").CombinedOutput()
exepath := filepath.Join(tmpDir, "testaddr2line.exe")
out, err := exec.Command(testenv.GoToolPath(t), "build", "-o", exepath, "cmd/addr2line").CombinedOutput()
if err != nil {
t.Fatalf("go build -o %v cmd/addr2line: %v\n%s", exepath, err, string(out))
}

Some files were not shown because too many files have changed in this diff Show More