diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE index 00014e9b86b..2e978b61380 100644 --- a/.github/PULL_REQUEST_TEMPLATE +++ b/.github/PULL_REQUEST_TEMPLATE @@ -1,7 +1,25 @@ -Please do not send pull requests to the golang/* repositories. +This PR will be imported into Gerrit with the title and first +comment (this text) used to generate the subject and body of +the Gerrit change. -We do, however, take contributions gladly. +**Please ensure you adhere to every item in this list.** -See https://golang.org/doc/contribute.html +More info can be found at https://github.com/golang/go/wiki/CommitMessage -Thanks! ++ The PR title is formatted as follows: `net/http: frob the quux before blarfing` + + The package name goes before the colon + + The part after the colon uses the verb tense + phrase that completes the blank in, + "This change modifies Go to ___________" + + Lowercase verb after the colon + + No trailing period + + Keep the title as short as possible. ideally under 76 characters or shorter ++ No Markdown ++ The first PR comment (this one) is wrapped at 76 characters, unless it's + really needed (ASCII art, table, or long link) ++ If there is a corresponding issue, add either `Fixes #1234` or `Updates #1234` + (the latter if this is not a complete fix) to this comment ++ If referring to a repo other than `golang/go` you can use the + `owner/repo#issue_number` syntax: `Fixes golang/tools#1234` ++ We do not use Signed-off-by lines in Go. Please don't add them. + Our Gerrit server & GitHub bots enforce CLA compliance instead. ++ Delete these instructions once you have read and applied them diff --git a/AUTHORS b/AUTHORS index c510d4b87b9..6c3ac3db616 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,13 +18,18 @@ Abe Haskins Abhinav Gupta Adam Eijdenberg Adam Kisala +Adam Thomason Aditya Mukerjee +Adrian Hesketh Adrian Nos Adrian O'Grady Adrien Bustany Aécio Júnior +Aeneas Rekkas (arekkas) +Afanasev Stanislav Agis Anastasopoulos -Ahmed Waheed Moanes +Agniva De Sarker +Ahmed Wahed Ahmy Yulrizka Aiden Scandella Ainar Garipov @@ -60,6 +65,7 @@ Alexander Menzhinsky Alexander Morozov Alexander Neumann Alexander Orlov +Alexander Pantyukhin Alexander Reece Alexander Surma Alexander Zhavnerchik @@ -67,6 +73,7 @@ Alexander Zolotov Alexandre Cesaro Alexandre Fiori Alexandre Normand +Alexandre Parentea Alexei Sholik Alexey Borzenkov Alexey Neganov @@ -76,9 +83,11 @@ Aliaksandr Valialkin Alif Rachmawadi Allan Simon Alok Menghrajani +Aman Gupta Amazon.com, Inc Amir Mohammad Saied Amrut Joshi +Anand K. Mistry Anders Pearson André Carvalho Andre Nathan @@ -104,7 +113,10 @@ Andrew Wilkins Andrew Williams Andrey Mirtchovski Andrey Petrov +Andrii Soldatenko +Andrii Soluk Andriy Lytvynov +Andrzej Żeżel Andy Balholm Andy Davis Andy Finkenstadt @@ -115,9 +127,11 @@ Angelo Bulfone Anh Hai Trinh Anmol Sethi Anschel Schaffer-Cohen +Anthony Alves Anthony Canino Anthony Eufemio Anthony Martin +Anthony Sottile Anthony Starks Anthony Voutas Anthony Woods @@ -128,6 +142,7 @@ Apisak Darakananda Apsalar Aram Hăvărneanu Areski Belaid +Ariel Mashraki Arlo Breault ARM Ltd. Arnaud Ysmal @@ -143,12 +158,14 @@ Augusto Roman Aulus Egnatius Varialus awaw fumin Awn Umar +Axel Wagner Ayanamist Yang Aymerick Jéhanne Baiju Muthukadan Bartosz Grzybowski Bastian Ike Ben Burkert +Ben Haines Ben Lubar Ben Olive Ben Shi @@ -159,26 +176,33 @@ Berengar Lehr Billie Harold Cleek Bjorn Tillenius Bjorn Tipling +Blain Smith Blake Gentry +Blake Mesdag Blake Mizerany Blixt Bobby Powers Bolt +Borja Clemente +Brad Burch Brady Catherman Brady Sullivan Brendan Daniel Tracey Brett Cannon +Brett Merrill Brian Dellisanti Brian Downs Brian G. Merrell Brian Gitonga Marete Brian Kennedy +Brian Kessler Brian Ketelsen Brian Smith Brian Starke Bryan Alexander Bryan Ford Bulat Gaifullin +Burak Guven Caine Tighe Caleb Spare Carl Chatfield @@ -193,9 +217,12 @@ Case Nelson Casey Marshall Cezar Sá Espinola ChaiShushan +Charles Fenwick Elliott Charles L. Dorian Charles Lee Chew Choon Keat +Cholerae Hu +Chris Ball Chris Biscardi Chris Dollin Chris Farmiloe @@ -207,6 +234,7 @@ Chris Lennert Chris McGee Chris Roche Chris Stockton +Christian Alexander Christian Couder Christian Himpel Christine Hansmann @@ -214,10 +242,12 @@ Christoffer Buchholz Christoph Hack Christopher Cahoon Christopher Guiney +Christopher Henderson Christopher Nelson Christopher Nielsen Christopher Redden Christopher Wedgwood +Christos Zoulas CL Sung Clement Skau CloudFlare Inc. @@ -251,6 +281,8 @@ Daniel Skinner Daniel Speichert Daniel Theophanes Daniel Upton +Daniela Petruzalek +Danny Rosseau Darren Elwood Datong Sun Dave Cheney @@ -272,6 +304,7 @@ David Thomas David Titarenco David Volquartz Lebech Davies Liu +Davor Kapsa Dean Prichard Deepak Jois Denis Bernard @@ -308,15 +341,19 @@ Dustin Sallings Dustin Shields-Cloues Dvir Volk Dylan Waits +Edan Bedrik <3d4nb3@gmail.com> Eden Li Edward Muller Egon Elbre Ehren Kret Eitan Adler Eivind Uggedal +Elbert Fliek +Elena Grahovac Elias Naur Elliot Morrison-Reed -Emil Hessman +Emerson Lin +Emil Hessman Emilien Kenler Emmanuel Odeke Empirical Interfaces Inc. @@ -326,6 +363,7 @@ Eric Clark Eric Engestrom Eric Lagergren Eric Milliken +Eric Rescorla Eric Roshan-Eisner Erik Aigner Erik Dubbelboer @@ -335,6 +373,7 @@ Ernest Chiang Esko Luontola Euan Kemp Evan Hicks +Evan Jones Evan Phoenix Evan Shaw Evgeniy Polyakov @@ -363,6 +402,8 @@ Ford Hurley Francisco Claude Francisco Rojas Francisco Souza +Frank Somers +Frederic Guillot Frederick Kelly Mayle III Fredrik Enestad Fredrik Forsmo @@ -391,9 +432,12 @@ Google Inc. Gordon Klaus Graham King Graham Miller +Grant Griffiths Greg Poirier Greg Ward Gregory Man +Guilherme Garnier +Guilherme Rezende Guillaume J. Charmes Guobiao Mei Gustav Paul @@ -404,6 +448,7 @@ Gyu-Ho Lee H. İbrahim Güngör Hajime Hoshi Hang Qian +Hanjun Kim Hari haran Hariharan Srinath Harley Laue @@ -416,8 +461,12 @@ Hector Martin Cantero Henning Schmiedehausen Henrik Edwards Henrik Hodne +Henry Adi Sumarto +Henry Bubert Henry Chang Herbert Georg Fischer +Hilko Bengen +Hiroaki Nakamura Hironao OTSUBO Hiroshi Ioka Hitoshi Mitake @@ -428,6 +477,7 @@ Hsin-Ho Yeh Hu Keping Hugues Bruant Ian Gudger +Ian Kent IBM Ibrahim AshShohail Icarus Sparry @@ -435,13 +485,16 @@ Iccha Sethi Idora Shinatose Igneous Systems, Inc. Igor Dolzhikov +Igor Vashyst INADA Naoki +Inanc Gumus Ingo Krabbe Ingo Oeser Intel Corporation Irieda Noboru Isaac Wagner Ivan Babrou +Ivan Bertona Ivan Moscoso Ivan Ukhov Jacob Hoffman-Andrews @@ -455,6 +508,7 @@ James David Chalfant James Fysh James Gray James Hartig +James Lawrence James Meneghello James Myers James Neve @@ -463,6 +517,7 @@ James Schofield James Smith James Sweet James Toy +James Treanor James Whitehead Jamie Beverly Jamie Kerr @@ -474,19 +529,25 @@ Jan Mercl <0xjnml@gmail.com> Jan Newmarch Jan Ziak <0xe2.0x9a.0x9b@gmail.com> Jani Monoses +Jared Culp Jaroslavas Počepko Jason Barnett Jason Chu Jason Del Ponte Jason Smale Jason Travis +Jason Wangsadinata +Javier Segura Jay Weisskopf +Jean-Francois Cantin Jean-Nicolas Moal +Jeet Parekh Jeff Hodges Jeff R. Allen Jeff Sickel Jeff Wendling Jeffrey H +Jelte Fennema Jens Frederich Jeremy Jackins Jeroen Bobbeldijk @@ -494,12 +555,14 @@ Jess Frazelle Jesse Szwedko Jihyun Yu Jim McGrath +Jimmy Frasche Jimmy Zelinskie Jin-wook Jeong Jingcheng Zhang Jingguo Yao Jiong Du Jirka Daněk +Jiulong Wang Joakim Sernbrant Joe Farrell Joe Harrison @@ -545,14 +608,18 @@ Josh Goebel Josh Holland Josh Roppo Joshua Chase +Joshua Rubin Josselin Costanzi Jostein Stuhaug Joyent, Inc. JT Olds +Juan Carlos +Jude Pereira Jukka-Pekka Kekkonen Julian Kornberger Julian Phillips Julien Schmidt +Junya Hayashi Justin Nuß Justyn Temme Kai Backman @@ -562,7 +629,9 @@ Kaleb Elwert Kamil Chmielewski Kamil Kisiel Kang Hu +Karel Pazdera Karoly Negyesi +Karsten Köhler Kashav Madan Kate Manson Kato Kazuyoshi @@ -579,13 +648,17 @@ Ken Friedenbach Ken Rockot Ken Sedgwick Kenji Kaneda +Kenji Yano Kenneth Shaw Kenny Grant Kevin Ballard Kevin Burke Kevin Kirsche +Kevin Ruffin Kevin Vu +Kieran Colford Kim Yongbin +Kirk Han Klaus Post Kodie Goodwin Koichi Shiraishi @@ -596,20 +669,26 @@ KPCompass, Inc. Kris Nova Kristopher Watts Kun Li +Kunpei Sakai Kyle Consalus Kyle Isom Kyle Jones Kyle Lemons +Kyle Shannon +Kyohei Kadota Kyrylo Silin L Campbell Lai Jiangshan +Lakshay Garg Lars Jeppesen Lars Wiegman Larz Conwell +Laurent Voisin Laurie Clark-Michalek LE Manh Cuong Lee Hinman Lee Packham +Leigh McCulloch Leon Klingele Lev Shamardin Lewin Bormann @@ -629,10 +708,15 @@ Luigi Riefolo Luit van Drongelen Luka Zakrajšek Luke Curley +Luke Granger-Brown +Lyle Franklin Ma Peiqi +Maicon Costa Maksym Trykur Mal Curtis Manfred Touron +Manish Goregaokar +Mansour Rahimi Manu S Ajith Manuel Mendez Marc Weistroff @@ -642,8 +726,11 @@ Marco Hennings Marin Bašić Mark Adams Mark Bucciarelli +Mark Percival +Mark Pulford Mark Severson Mark Theunissen +Mark Wolfe Marko Juhani Silokunnas Marko Mudrinic Marko Tiikkaja @@ -661,13 +748,17 @@ Martin Neubauer Martin Olsen Martin Olsson Martin Probst +Martins Sipenko Marvin Stenger Marwan Sulaiman Maryan Hratson Masahiro Furudate Masahiro Wakame Masaki Yoshida +Mat Byczkowski Máté Gulyás +Matej Baćo +Mateus Amin Mateusz Czapliński Mathias Beke Mathias Hall-Andersen @@ -677,6 +768,7 @@ Mats Lidell Matt Aimonetti Matt Blair Matt Bostock +Matt Dee Matt Drollette Matt Harden Matt Jibson @@ -688,23 +780,28 @@ Matt Strong Matt T. Proud Matt Williams Matthew Brennan +Matthew Broberg Matthew Cottingham Matthew Denton Matthew Holt Matthew Horsnell Matthieu Hauglustaine Matthieu Olivier +Matthijs Kooijman Max Riveiro +Max Schmitt Maxim Khitrov Maxime de Roucy Máximo Cuadros Ortiz Maxwell Krohn +Mayank Kumar MediaMath, Inc Meir Fischer Meng Zhuo Meteor Development Group Mhd Sulhan Micah Stetson +Michael Brandenburg Michael Chaten Michael Edwards Michael Elkins @@ -716,17 +813,22 @@ Michael Käufl Michael Lewis Michael MacInnis Michael McConville +Michael McLoughlin Michael Pearson Michael Schaller +Michael Schurter Michael Stapelberg +Michael Steinert Michael Teichgräber Michael Vetter Michal Bohuslávek Michał Derkacz +Michal Pristas Miek Gieben Miguel Mendez Miguel Molina Mihai Borobocea +Mihail Minaev Mikael Tillenius Mike Andrews Mike Appleby @@ -748,9 +850,11 @@ Moriyoshi Koizumi Morten Siebuhr Môshe van der Sterre Mostyn Bramley-Moore +Muhammad Falak R Wani Muhammed Uluyol Mura Li Nan Deng +Naoki Kanatani Nathan Caza Nathan Humphreys Nathan John Youngman @@ -779,6 +883,7 @@ Nick Miyake Nick Patavalis Nick Petroni Nick Robinson +Nicolas BRULEZ Nicolas Kaiser Nicolas Owens Nicolas S. Dade @@ -788,8 +893,10 @@ Nik Nyby Niklas Schnelle Niko Dziemba Nikolay Turpitko +Nils Larsgård Niranjan Godbole Noah Campbell +Noble Johnson Norberto Lopes Odin Ugedal Oleg Bulatov @@ -823,12 +930,15 @@ Patrick Mylund Nielsen Patrick Pelletier Patrick Smith Paul A Querna +Paul Boyd Paul Hammond Paul Jolly Paul Lalonde Paul Meyer +Paul PISCUC Paul Querna Paul Rosania +Paul Ruest Paul Sbarra Paul Smith Paul van Brouwershaven @@ -853,6 +963,7 @@ Péter Szilágyi Peter Waldschmidt Peter Waller Peter Williams +Petrica Voicu Philip Børgesen Philip Hofer Philip K. Warren @@ -861,26 +972,34 @@ Pierre Roullon Piers Pieter Droogendijk Pietro Gagliardi +Pontus Leitzler Prashant Varanasi Pravendra Singh Preetam Jinka Qiuxuan Zhu +Qualcomm Data Center, Inc. Quan Tran Quan Yong Zhai Quentin Perez Quentin Renard Quoc-Viet Nguyen RackTop Systems Inc. +Radek Sohlich Radu Berinde Rafal Jeczalik Raif S. Naffah RainTank Rajat Goel +Rajath Agasthya +Rajender Reddy Kompally Ralph Corderoy +Ramazan AYYILDIZ Raphael Geronimi +RaviTeja Pothana Ray Tung Raymond Kazlauskas Red Hat, Inc. +Reilly Watson Reinaldo de Souza Jr Remi Gillig Rémy Oudompheng @@ -909,10 +1028,13 @@ Rodrigo Rafael Monti Kochenburger Roger Pau Monné Roger Peppe Roland Shoemaker +Roman Budnikov Ron Hashimoto Ron Minnich +Ross Chater Ross Light Rowan Worth +Rudi Kramer Russell Haering Ryan Bagwell Ryan Boehning @@ -920,6 +1042,8 @@ Ryan Hitchman Ryan Lower Ryan Seys Ryan Slade +Ryoichi KATO +Ryuji Iwata Ryuzo Yamamoto S.Çağlar Onur Sakeven Jiang @@ -933,15 +1057,19 @@ Sascha Brawer Sasha Sobol Scott Barron Scott Bell +Scott Crunkleton Scott Ferguson Scott Lawrence Sean Rees Sebastien Binet Sébastien Paolacci +Seiji Takahashi Sergei Skorobogatov Sergey 'SnakE' Gromov Sergey Mishin +Sergey Semin Sergio Luis O. B. Correia +Sergiusz Bazanski Seth Hoenig Seth Vargo Shahar Kohanim @@ -968,11 +1096,13 @@ Square, Inc. Sridhar Venkatakrishnan StalkR Stan Schwertly +Stanislav Afanasev Stefan Nilsson Stéphane Travostino Stephen McQuay Stephen Searles Stephen Weinberg +Steve Gilbert Steve McCoy Steve Phillips Steve Streeting @@ -981,46 +1111,57 @@ Steven Erenst Steven Hartland Steven Wilkin Stripe, Inc. +Sukrit Handa Sunny Suyash Sven Almgren +Sylvain Zimmer Syohei YOSHIDA Szabolcs Nagy +Tad Fisher Tad Glines Taj Khattra Takeshi YAMANASHI <9.nashi@gmail.com> Takuya Ueda Tal Shprecher Tamir Duberstein +Tao Wang Tarmigan Casebolt Taro Aoki Taru Karttunen Tatsuhiro Tsujikawa Ted Kornish Teleport Inc. +Terin Stock Terrel Shumway Tetsuo Kiso Thanatat Tamtan +Thiago Avelino Thiago Fransosi Farina Thomas Alan Copeland Thomas Bonfort Thomas de Zeeuw Thomas Desrosiers Thomas Kappler +Thomas Wanielista Thorben Krueger Thordur Bjornsson Tilman Dilo Tim Cooijmans +Tim Cooper Tim Ebringer Tim Heckman Tim Henderson +Tim Wright Timo Savola Timo Truyts Timothy Studd +Tobias Assarsson Tobias Columbus Tobias Klauser Todd Neal Tom Heng +Tom Levy Tom Linford Tommy Schaefer Tonis Tiigi @@ -1035,8 +1176,10 @@ Trey Roessig Trey Tacon Tristan Colgate Tristan Ooohry +Troels Thomsen Trung Nguyen Tudor Golubenco +Tugdual Saunier Tuo Shan Tyler Bunnell Tyler Treat @@ -1063,14 +1206,18 @@ Volker Dobler Wade Simmons Wander Lairson Costa Weaveworks +Wèi Cōngruì Wei Guangjing Weichao Tang +Wembley G. Leach, Jr +Will Faught Will Storey Willem van der Schyff William Josephson William Orr Wisdom Omuya Wu Yunzhou +Xi Ruoyao Xia Bin Xing Xing Xu Fei @@ -1078,30 +1225,36 @@ Xudong Zhang Xuyang Kang Yahoo Inc. Yann Kerhervé +Yann Salaün Yao Zhang Yasha Bubnov Yasuharu Goto Yasuhiro Matsumoto Yestin Sun -Yesudeep Mangalapilly Yissakhar Z. Beck Yo-An Lin Yongjian Xu Yorman Arias Yoshiyuki Kanno +Yosuke Akatsuka +Yukihiro Nishinaka <6elpinal@gmail.com> Yusuke Kagiwada Yuusei Kuwana Yuval Pavel Zholkover Zac Bergquist Zach Bintliff +Zach Gershman Zak Zakatell Kanda Zellyn Hunter Zemanta d.o.o. Zev Goldstein +Zhongtao Chen Ziad Hatahet Zorion Arrizabalaga Максим Федосеев +Роман Хавроненко +Тарас Буник Фахриддин Балтаев 张嵩 申习之 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4f2c4d4b02f..7c1dd54b302 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,11 +30,6 @@ For change proposals, see [Proposing Changes To Go](https://github.com/golang/pr 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 -[Gerrit](https://www.gerritcodereview.com/) code review system instead). -Also, please do not post patches on the issue tracker. - Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file. diff --git a/CONTRIBUTORS b/CONTRIBUTORS index b1854edfc6b..f76e5156de1 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -44,13 +44,18 @@ Adam Bender Adam Eijdenberg Adam Kisala Adam Langley +Adam Thomason Aditya Mukerjee +Adrian Hesketh Adrian Nos Adrian O'Grady Adrien Bustany Aécio Júnior +Aeneas Rekkas (arekkas) +Afanasev Stanislav Agis Anastasopoulos -Ahmed Waheed Moanes +Agniva De Sarker +Ahmed Wahed Ahmet Alp Balkan Ahmy Yulrizka Aiden Scandella @@ -90,6 +95,7 @@ Alexander Menzhinsky Alexander Morozov Alexander Neumann Alexander Orlov +Alexander Pantyukhin Alexander Polcyn Alexander Reece Alexander Surma @@ -98,6 +104,7 @@ Alexander Zolotov Alexandre Cesaro Alexandre Fiori Alexandre Normand +Alexandre Parentea Alexandru Moșoi Alexei Sholik Alexey Borzenkov @@ -110,8 +117,10 @@ Aliaksandr Valialkin Alif Rachmawadi Allan Simon Alok Menghrajani +Aman Gupta Amir Mohammad Saied Amrut Joshi +Anand K. Mistry Anders Pearson André Carvalho Andre Nathan @@ -144,7 +153,10 @@ Andrew Wilkins Andrew Williams Andrey Mirtchovski Andrey Petrov +Andrii Soldatenko +Andrii Soluk Andriy Lytvynov +Andrzej Żeżel Andy Balholm Andy Davis Andy Finkenstadt @@ -155,9 +167,11 @@ Angelo Bulfone Anh Hai Trinh Anmol Sethi Anschel Schaffer-Cohen +Anthony Alves Anthony Canino Anthony Eufemio Anthony Martin +Anthony Sottile Anthony Starks Anthony Voutas Anthony Woods @@ -168,6 +182,7 @@ Antonio Troina Apisak Darakananda Aram Hăvărneanu Areski Belaid +Ariel Mashraki Arkadi Pyuro Arlo Breault Arnaud Ysmal @@ -185,6 +200,7 @@ Aulus Egnatius Varialus Austin Clements awaw fumin Awn Umar +Axel Wagner Ayanamist Yang Aymerick Jéhanne Baiju Muthukadan @@ -194,9 +210,12 @@ Bastian Ike Ben Burkert Ben Eitzen Ben Fried +Ben Haines +Ben Laurie Ben Lubar Ben Lynn Ben Olive +Ben Schwartz Ben Shi Benjamin Black Benjamin Prosnitz @@ -212,11 +231,15 @@ Billie Harold Cleek Billy Lynch Bjorn Tillenius Bjorn Tipling +Blain Smith Blake Gentry +Blake Mesdag Blake Mizerany Blixt Bobby Powers Boris Nagaev +Borja Clemente +Brad Burch Brad Fitzpatrick Brad Garcia Brad Jones @@ -229,11 +252,13 @@ Brandon Gilmore Brendan Daniel Tracey Brendan O'Dea Brett Cannon +Brett Merrill Brian Dellisanti Brian Downs Brian G. Merrell Brian Gitonga Marete Brian Kennedy +Brian Kessler Brian Ketelsen Brian Slesinsky Brian Smith @@ -243,6 +268,7 @@ Bryan C. Mills Bryan Chan Bryan Ford Bulat Gaifullin +Burak Guven Caine Tighe Caio Marcelo de Oliveira Filho Caleb Spare @@ -266,11 +292,14 @@ Catalin Patulea Cedric Staub Cezar Sá Espinola ChaiShushan +Charles Fenwick Elliott Charles L. Dorian Charles Lee Charles Weill Cherry Zhang Chew Choon Keat +Cholerae Hu +Chris Ball Chris Biscardi Chris Broadfoot Chris Dollin @@ -287,6 +316,7 @@ Chris Raynor Chris Roche Chris Stockton Chris Zou +Christian Alexander Christian Couder Christian Himpel Christine Hansmann @@ -294,11 +324,14 @@ Christoffer Buchholz Christoph Hack Christopher Cahoon Christopher Guiney +Christopher Henderson +Christopher Koch Christopher Nelson Christopher Nielsen Christopher Redden Christopher Swenson Christopher Wedgwood +Christos Zoulas Christy Perez CL Sung Clement Skau @@ -341,6 +374,8 @@ Daniel Skinner Daniel Speichert Daniel Theophanes Daniel Upton +Daniela Petruzalek +Danny Rosseau Daria Kolistratova Darren Elwood Datong Sun @@ -379,6 +414,7 @@ David Thomas David Titarenco David Volquartz Lebech Davies Liu +Davor Kapsa Dean Prichard Deepak Jois Denis Bernard @@ -425,15 +461,19 @@ Dustin Sallings Dustin Shields-Cloues Dvir Volk Dylan Waits +Edan Bedrik <3d4nb3@gmail.com> Eden Li Edward Muller Egon Elbre Ehren Kret Eitan Adler Eivind Uggedal +Elbert Fliek +Elena Grahovac Elias Naur Elliot Morrison-Reed -Emil Hessman +Emerson Lin +Emil Hessman Emilien Kenler Emmanuel Odeke Eoghan Sherry @@ -444,6 +484,7 @@ Eric Garrido Eric Koleda Eric Lagergren Eric Milliken +Eric Rescorla Eric Roshan-Eisner Erik Aigner Erik Dubbelboer @@ -458,6 +499,7 @@ Euan Kemp Evan Broder Evan Brown Evan Hicks +Evan Jones Evan Kroske Evan Martin Evan Phoenix @@ -481,7 +523,7 @@ Fedor Indutny Felipe Oliveira Felix Geisendörfer Filip Gruszczyński -Filippo Valsorda +Filippo Valsorda Firmansyah Adiputra Florian Uekermann Florian Weimer @@ -492,6 +534,8 @@ Francesc Campoy Francisco Claude Francisco Rojas Francisco Souza +Frank Somers +Frederic Guillot Frederick Kelly Mayle III Fredrik Enestad Fredrik Forsmo @@ -504,6 +548,7 @@ Gabriel Aszalos Gabriel Nicolas Avellaneda Gabriel Russell Gareth Paul Jones +Garret Kelly Garrick Evans Gary Burd Gary Elliott @@ -511,6 +556,7 @@ Gaurish Sharma Gautham Thambidorai Geert-Johan Riemer Gengliang Wang +Geoff Berry Geoffroy Lorieux Georg Reinke George Gkirtsou @@ -526,9 +572,12 @@ Glenn Lewis Gordon Klaus Graham King Graham Miller +Grant Griffiths Greg Poirier Greg Ward Gregory Man +Guilherme Garnier +Guilherme Rezende Guillaume J. Charmes Guobiao Mei Gustav Paul @@ -542,6 +591,7 @@ Hajime Hoshi Hallgrimur Gunnarsson Han-Wen Nienhuys Hang Qian +Hanjun Kim Hari haran Hariharan Srinath Harley Laue @@ -554,9 +604,14 @@ Hector Martin Cantero Henning Schmiedehausen Henrik Edwards Henrik Hodne +Henry Adi Sumarto +Henry Bubert Henry Chang Herbert Georg Fischer +Herbie Ong Heschi Kreinick +Hilko Bengen +Hiroaki Nakamura Hironao OTSUBO Hiroshi Ioka Hitoshi Mitake @@ -570,6 +625,7 @@ Hu Keping Hugues Bruant Hyang-Ah Hana Kim Ian Gudger +Ian Kent Ian Lance Taylor Ibrahim AshShohail Icarus Sparry @@ -577,13 +633,17 @@ Iccha Sethi Idora Shinatose Igor Bernstein Igor Dolzhikov +Igor Vashyst Ilya Tocar INADA Naoki +Inanc Gumus Ingo Krabbe Ingo Oeser Irieda Noboru Isaac Wagner +Iskander Sharipov Ivan Babrou +Ivan Bertona Ivan Krasin Ivan Moscoso Ivan Ukhov @@ -605,6 +665,7 @@ James David Chalfant James Fysh James Gray James Hartig +James Lawrence James Meneghello James Myers James Neve @@ -614,11 +675,13 @@ James Schofield James Smith James Sweet James Toy +James Treanor James Tucker James Whitehead Jamie Beverly Jamie Gennis Jamie Kerr +Jamie Liu Jamie Stackhouse Jamie Turner Jamie Wilkinson @@ -630,6 +693,7 @@ Jan Mercl <0xjnml@gmail.com> Jan Newmarch Jan Ziak <0xe2.0x9a.0x9b@gmail.com> Jani Monoses +Jared Culp Jaroslavas Počepko Jason Barnett Jason Buberel @@ -638,11 +702,15 @@ Jason Del Ponte Jason Hall Jason Smale Jason Travis +Jason Wangsadinata +Javier Segura Jay Conrod Jay Weisskopf +Jean-Francois Cantin Jean-Marc Eurin Jean-Nicolas Moal Jed Denlea +Jeet Parekh Jeff (Zhefu) Jiang Jeff Craig Jeff Hodges @@ -651,6 +719,7 @@ Jeff R. Allen Jeff Sickel Jeff Wendling Jeffrey H +Jelte Fennema Jens Frederich Jeremiah Harmsen Jeremy Jackins @@ -664,12 +733,14 @@ Jihyun Yu Jim Cote Jim Kingdon Jim McGrath +Jimmy Frasche Jimmy Zelinskie Jin-wook Jeong Jingcheng Zhang Jingguo Yao Jiong Du Jirka Daněk +Jiulong Wang Joakim Sernbrant Joe Farrell Joe Harrison @@ -734,10 +805,13 @@ Josh Holland Josh Roppo Joshua Boelter Joshua Chase +Joshua Rubin Josselin Costanzi Jostein Stuhaug JP Sugarbroad JT Olds +Juan Carlos +Jude Pereira Jukka-Pekka Kekkonen Julia Hansbrough Julian Kornberger @@ -746,6 +820,7 @@ Julian Phillips Julien Schmidt Julio Montes Jungho Ahn +Junya Hayashi Jure Ham Justin Nuß Justyn Temme @@ -758,7 +833,9 @@ Kamil Chmielewski Kamil Kisiel Kang Hu Karan Dhiman +Karel Pazdera Karoly Negyesi +Karsten Köhler Kashav Madan Kate Manson Kato Kazuyoshi @@ -779,6 +856,7 @@ Ken Rockot Ken Sedgwick Ken Thompson Kenji Kaneda +Kenji Yano Kenneth Shaw Kenny Grant Kevin Ballard @@ -786,10 +864,13 @@ Kevin Burke Kevin Kirsche Kevin Klues Kevin Malachowski +Kevin Ruffin Kevin Vu +Kieran Colford Kim Shrier Kim Yongbin Kirill Smelkov +Kirk Han Kirklin McDonald Klaus Post Kodie Goodwin @@ -801,31 +882,40 @@ Kris Nova Kris Rousey Kristopher Watts Kun Li +Kunpei Sakai Kyle Consalus Kyle Isom Kyle Jones Kyle Lemons +Kyle Shannon +Kyohei Kadota Kyrylo Silin L Campbell Lai Jiangshan +Lakshay Garg +Lann Martin Larry Hosken Lars Jeppesen Lars Wiegman Larz Conwell +Laurent Voisin Laurie Clark-Michalek LE Manh Cuong Lee Hinman Lee Packham +Leigh McCulloch Leo Rudberg Leon Klingele Lev Shamardin Lewin Bormann Lion Yang Lloyd Dewolf +Lorenz Bauer Lorenzo Masini Lorenzo Stoakes Louis Kruger Luan Santos +Luca Bruno Luca Greco Lucas Bremgartner Lucas Clemente @@ -837,15 +927,20 @@ Luit van Drongelen Luka Zakrajšek Lukasz Milewski Luke Curley +Luke Granger-Brown Luna Duclos Luuk van Dijk +Lyle Franklin Lynn Boger Ma Peiqi Magnus Hiie +Maicon Costa Maksym Trykur Mal Curtis Manfred Touron +Manish Goregaokar Manoj Dayaram +Mansour Rahimi Manu Garg Manu S Ajith Manuel Mendez @@ -861,9 +956,12 @@ Marius Nuennerich Mark Adams Mark Bucciarelli Mark Harrison +Mark Percival +Mark Pulford Mark Ryan Mark Severson Mark Theunissen +Mark Wolfe Mark Zavislak Marko Juhani Silokunnas Marko Mikulicic @@ -884,6 +982,7 @@ Martin Neubauer Martin Olsen Martin Olsson Martin Probst +Martins Sipenko Martynas Budriūnas Marvin Stenger Marwan Sulaiman @@ -891,7 +990,10 @@ Maryan Hratson Masahiro Furudate Masahiro Wakame Masaki Yoshida +Mat Byczkowski Máté Gulyás +Matej Baćo +Mateus Amin Mateusz Czapliński Mathias Beke Mathias Hall-Andersen @@ -902,6 +1004,7 @@ Matt Aimonetti Matt Blair Matt Bostock Matt Brown +Matt Dee Matt Drollette Matt Harden Matt Jibson @@ -914,6 +1017,7 @@ Matt Strong Matt T. Proud Matt Williams Matthew Brennan +Matthew Broberg Matthew Cottingham Matthew Dempsky Matthew Denton @@ -921,17 +1025,21 @@ Matthew Holt Matthew Horsnell Matthieu Hauglustaine Matthieu Olivier +Matthijs Kooijman Max Riveiro +Max Schmitt Maxim Khitrov Maxim Pimenov Maxim Ushakov Maxime de Roucy Máximo Cuadros Ortiz Maxwell Krohn +Mayank Kumar Meir Fischer Meng Zhuo Mhd Sulhan Micah Stetson +Michael Brandenburg Michael Chaten Michael Darakananda Michael Edwards @@ -949,25 +1057,30 @@ Michael Marineau Michael Matloob Michael McConville Michael McGreevy +Michael McLoughlin Michael Munday Michael Pearson Michael Piatek Michael Pratt Michael Schaller +Michael Schurter Michael Shields Michael Stapelberg +Michael Steinert Michael T. Jones Michael Teichgräber Michael Vetter Michal Bohuslávek Michal Cierniak Michał Derkacz +Michal Pristas Michalis Kargakis Michel Lespinasse Miek Gieben Miguel Mendez Miguel Molina Mihai Borobocea +Mihail Minaev Mikael Tillenius Mike Andrews Mike Appleby @@ -995,9 +1108,11 @@ Morten Siebuhr Môshe van der Sterre Mostyn Bramley-Moore Mrunal Patel +Muhammad Falak R Wani Muhammed Uluyol Mura Li Nan Deng +Naoki Kanatani Nathan Caza Nathan Humphreys Nathan John Youngman @@ -1027,6 +1142,7 @@ Nick Miyake Nick Patavalis Nick Petroni Nick Robinson +Nicolas BRULEZ Nicolas Kaiser Nicolas Owens Nicolas S. Dade @@ -1037,8 +1153,10 @@ Nik Nyby Niklas Schnelle Niko Dziemba Nikolay Turpitko +Nils Larsgård Niranjan Godbole Noah Campbell +Noble Johnson Nodir Turakulov Norberto Lopes Odin Ugedal @@ -1073,6 +1191,7 @@ Patrick Riley Patrick Smith Paul A Querna Paul Borman +Paul Boyd Paul Chang Paul Hammond Paul Hankin @@ -1081,8 +1200,10 @@ Paul Lalonde Paul Marks Paul Meyer Paul Nasrat +Paul PISCUC Paul Querna Paul Rosania +Paul Ruest Paul Sbarra Paul Smith Paul van Brouwershaven @@ -1116,6 +1237,8 @@ Peter Waldschmidt Peter Waller Peter Weinberger Peter Williams +Peter Wu +Petrica Voicu Phil Pennock Philip Børgesen Philip Hofer @@ -1125,6 +1248,7 @@ Pierre Roullon Piers Pieter Droogendijk Pietro Gagliardi +Pontus Leitzler Prasanna Swaminathan Prashant Varanasi Pravendra Singh @@ -1137,19 +1261,25 @@ Quentin Renard Quentin Smith Quinn Slack Quoc-Viet Nguyen +Radek Sohlich Radu Berinde Rafal Jeczalik Rahul Chaudhry Raif S. Naffah Rajat Goel +Rajath Agasthya +Rajender Reddy Kompally Ralph Corderoy +Ramazan AYYILDIZ Ramesh Dharan Raph Levien Raphael Geronimi Raul Silvera +RaviTeja Pothana Ray Tung Raymond Kazlauskas Rebecca Stambler +Reilly Watson Reinaldo de Souza Jr Remi Gillig Rémy Oudompheng @@ -1187,10 +1317,13 @@ Rodrigo Rafael Monti Kochenburger Roger Pau Monné Roger Peppe Roland Shoemaker +Roman Budnikov Ron Hashimoto Ron Minnich +Ross Chater Ross Light Rowan Worth +Rudi Kramer Rui Ueyama Russ Cox Russell Haering @@ -1202,6 +1335,8 @@ Ryan Hitchman Ryan Lower Ryan Seys Ryan Slade +Ryoichi KATO +Ryuji Iwata Ryuzo Yamamoto S.Çağlar Onur Sai Cheemalapati @@ -1223,6 +1358,7 @@ Sasha Lionheart Sasha Sobol Scott Barron Scott Bell +Scott Crunkleton Scott Ferguson Scott Lawrence Scott Mansfield @@ -1236,11 +1372,15 @@ Sean Harger Sean Rees Sebastien Binet Sébastien Paolacci +Seiji Takahashi Sergei Skorobogatov Sergey 'SnakE' Gromov Sergey Arseev +Sergey Frolov Sergey Mishin +Sergey Semin Sergio Luis O. B. Correia +Sergiusz Bazanski Seth Hoenig Seth Vargo Shahar Kohanim @@ -1270,6 +1410,7 @@ Srdjan Petrovic Sridhar Venkatakrishnan StalkR Stan Schwertly +Stanislav Afanasev Stefan Nilsson Stéphane Travostino Stephen Ma @@ -1277,6 +1418,7 @@ Stephen McQuay Stephen Searles Stephen Weinberg Steve Francia +Steve Gilbert Steve McCoy Steve Newman Steve Phillips @@ -1288,13 +1430,16 @@ Steven Hartland Steven Wilkin Sugu Sougoumarane Suharsh Sivakumar +Sukrit Handa Sunny Suyash Suzy Mueller Sven Almgren Sven Blumenstein +Sylvain Zimmer Syohei YOSHIDA Szabolcs Nagy +Tad Fisher Tad Glines Taj Khattra Takashi Matsuo @@ -1303,15 +1448,18 @@ Takuto Ikuta Takuya Ueda Tal Shprecher Tamir Duberstein +Tao Wang Tarmigan Casebolt Taro Aoki Taru Karttunen Tatsuhiro Tsujikawa Ted Kornish +Terin Stock Terrel Shumway Tetsuo Kiso Than McIntosh Thanatat Tamtan +Thiago Avelino Thiago Fransosi Farina Thomas Alan Copeland Thomas Bonfort @@ -1320,19 +1468,23 @@ Thomas de Zeeuw Thomas Desrosiers Thomas Habets Thomas Kappler +Thomas Wanielista Thorben Krueger Thordur Bjornsson Tilman Dilo Tim Cooijmans +Tim Cooper Tim Ebringer Tim Heckman Tim Henderson Tim Hockin Tim Swast +Tim Wright Timo Savola Timo Truyts Timothy Studd Tipp Moseley +Tobias Assarsson Tobias Columbus Tobias Klauser Toby Burress @@ -1340,6 +1492,8 @@ Todd Neal Todd Wang Tom Bergan Tom Heng +Tom Lanyon +Tom Levy Tom Linford Tom Szymanski Tom Wilkie @@ -1358,9 +1512,12 @@ Trey Tacon Tristan Amini Tristan Colgate Tristan Ooohry +Troels Thomsen Trung Nguyen Tudor Golubenco +Tugdual Saunier Tuo Shan +Tyler Bui-Palsulich Tyler Bunnell Tyler Treat Tzu-Jung Lee @@ -1393,10 +1550,13 @@ Wade Simmons Walter Poupore Wander Lairson Costa Wedson Almeida Filho +Wèi Cōngruì Wei Guangjing Wei Xiao Weichao Tang +Wembley G. Leach, Jr Will Chan +Will Faught Will Norris Will Storey Willem van der Schyff @@ -1405,6 +1565,7 @@ William Josephson William Orr Wisdom Omuya Wu Yunzhou +Xi Ruoyao Xia Bin Xing Xing Xu Fei @@ -1412,6 +1573,7 @@ Xudong Zhang Xuyang Kang Yan Zou Yann Kerhervé +Yann Salaün Yao Zhang Yasha Bubnov Yasuharu Goto @@ -1423,23 +1585,30 @@ Yo-An Lin Yongjian Xu Yorman Arias Yoshiyuki Kanno +Yosuke Akatsuka Yu Heng Zhang Yu Xuan Zhang Yuki Yugui Sonoda +Yukihiro Nishinaka <6elpinal@gmail.com> Yusuke Kagiwada Yuusei Kuwana Yuval Pavel Zholkover Yves Junqueira Zac Bergquist Zach Bintliff +Zach Gershman Zak Zakatell Kanda Zellyn Hunter Zev Goldstein +Zhengyu He +Zhongtao Chen Zhongwei Yao Ziad Hatahet Zorion Arrizabalaga Максим Федосеев +Роман Хавроненко +Тарас Буник Фахриддин Балтаев 张嵩 申习之 diff --git a/README.md b/README.md index 57492b3fb03..8cf23cae1e1 100644 --- a/README.md +++ b/README.md @@ -31,15 +31,14 @@ in your web browser for source installation instructions. ### Contributing -Go is the work of hundreds of contributors. We appreciate your help! +Go is the work of thousands 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 the Go project uses 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. [rf]: https://reneefrench.blogspot.com/ [cc3-by]: https://creativecommons.org/licenses/by/3.0/ diff --git a/api/README b/api/README index d3ad7c1d747..ce24efcd312 100644 --- a/api/README +++ b/api/README @@ -11,4 +11,3 @@ compatibility. next.txt is the only file intended to be mutated. It's a list of features that may be added to the next version. It only affects warning output from the go api tool. - diff --git a/api/except.txt b/api/except.txt index f8cd0faf646..997df042b65 100644 --- a/api/except.txt +++ b/api/except.txt @@ -2,6 +2,7 @@ pkg encoding/json, method (*RawMessage) MarshalJSON() ([]uint8, error) pkg math/big, const MaxBase = 36 pkg math/big, type Word uintptr pkg net, func ListenUnixgram(string, *UnixAddr) (*UDPConn, error) +pkg os, const ModeType = 2399141888 pkg os (linux-arm), const O_SYNC = 4096 pkg os (linux-arm-cgo), const O_SYNC = 4096 pkg syscall (darwin-386), const ImplementsGetwd = false @@ -15,25 +16,30 @@ pkg syscall (darwin-amd64-cgo), func Fchflags(string, int) error pkg syscall (freebsd-386), const AF_MAX = 38 pkg syscall (freebsd-386), const DLT_MATCHING_MAX = 242 pkg syscall (freebsd-386), const ELAST = 94 +pkg syscall (freebsd-386), const ImplementsGetwd = false pkg syscall (freebsd-386), const O_CLOEXEC = 0 pkg syscall (freebsd-386), func Fchflags(string, int) error pkg syscall (freebsd-386-cgo), const AF_MAX = 38 pkg syscall (freebsd-386-cgo), const DLT_MATCHING_MAX = 242 pkg syscall (freebsd-386-cgo), const ELAST = 94 +pkg syscall (freebsd-386-cgo), const ImplementsGetwd = false pkg syscall (freebsd-386-cgo), const O_CLOEXEC = 0 pkg syscall (freebsd-amd64), const AF_MAX = 38 pkg syscall (freebsd-amd64), const DLT_MATCHING_MAX = 242 pkg syscall (freebsd-amd64), const ELAST = 94 +pkg syscall (freebsd-amd64), const ImplementsGetwd = false pkg syscall (freebsd-amd64), const O_CLOEXEC = 0 pkg syscall (freebsd-amd64), func Fchflags(string, int) error pkg syscall (freebsd-amd64-cgo), const AF_MAX = 38 pkg syscall (freebsd-amd64-cgo), const DLT_MATCHING_MAX = 242 pkg syscall (freebsd-amd64-cgo), const ELAST = 94 +pkg syscall (freebsd-amd64-cgo), const ImplementsGetwd = false pkg syscall (freebsd-amd64-cgo), const O_CLOEXEC = 0 pkg syscall (freebsd-arm), const AF_MAX = 38 pkg syscall (freebsd-arm), const BIOCGRTIMEOUT = 1074545262 pkg syscall (freebsd-arm), const BIOCSRTIMEOUT = 2148287085 pkg syscall (freebsd-arm), const ELAST = 94 +pkg syscall (freebsd-arm), const ImplementsGetwd = false pkg syscall (freebsd-arm), const O_CLOEXEC = 0 pkg syscall (freebsd-arm), const SIOCAIFADDR = 2151967019 pkg syscall (freebsd-arm), const SIOCGIFSTATUS = 3274991931 @@ -65,6 +71,7 @@ pkg syscall (freebsd-arm-cgo), const AF_MAX = 38 pkg syscall (freebsd-arm-cgo), const BIOCGRTIMEOUT = 1074545262 pkg syscall (freebsd-arm-cgo), const BIOCSRTIMEOUT = 2148287085 pkg syscall (freebsd-arm-cgo), const ELAST = 94 +pkg syscall (freebsd-arm-cgo), const ImplementsGetwd = false pkg syscall (freebsd-arm-cgo), const O_CLOEXEC = 0 pkg syscall (freebsd-arm-cgo), const SIOCAIFADDR = 2151967019 pkg syscall (freebsd-arm-cgo), const SIOCGIFSTATUS = 3274991931 @@ -98,6 +105,12 @@ pkg syscall (linux-amd64), type Cmsghdr struct, X__cmsg_data [0]uint8 pkg syscall (linux-amd64-cgo), type Cmsghdr struct, X__cmsg_data [0]uint8 pkg syscall (linux-arm), type Cmsghdr struct, X__cmsg_data [0]uint8 pkg syscall (linux-arm-cgo), type Cmsghdr struct, X__cmsg_data [0]uint8 +pkg syscall (netbsd-386), const ImplementsGetwd = false +pkg syscall (netbsd-386-cgo), const ImplementsGetwd = false +pkg syscall (netbsd-amd64), const ImplementsGetwd = false +pkg syscall (netbsd-amd64-cgo), const ImplementsGetwd = false +pkg syscall (netbsd-arm), const ImplementsGetwd = false +pkg syscall (netbsd-arm-cgo), const ImplementsGetwd = false pkg syscall (netbsd-arm), const SizeofIfData = 132 pkg syscall (netbsd-arm), func Fchflags(string, int) error pkg syscall (netbsd-arm), type IfMsghdr struct, Pad_cgo_1 [4]uint8 @@ -106,6 +119,7 @@ pkg syscall (netbsd-arm-cgo), func Fchflags(string, int) error pkg syscall (netbsd-arm-cgo), type IfMsghdr struct, Pad_cgo_1 [4]uint8 pkg syscall (openbsd-386), const BIOCGRTIMEOUT = 1074283118 pkg syscall (openbsd-386), const BIOCSRTIMEOUT = 2148024941 +pkg syscall (openbsd-386), const ImplementsGetwd = false pkg syscall (openbsd-386), const RTF_FMASK = 63496 pkg syscall (openbsd-386), const RTM_VERSION = 4 pkg syscall (openbsd-386), const SIOCBRDGDADDR = 2150132039 @@ -158,6 +172,7 @@ pkg syscall (openbsd-386), type Timespec struct, Sec int32 pkg syscall (openbsd-386), type Timeval struct, Sec int32 pkg syscall (openbsd-386-cgo), const BIOCGRTIMEOUT = 1074283118 pkg syscall (openbsd-386-cgo), const BIOCSRTIMEOUT = 2148024941 +pkg syscall (openbsd-386-cgo), const ImplementsGetwd = false pkg syscall (openbsd-386-cgo), const RTF_FMASK = 63496 pkg syscall (openbsd-386-cgo), const RTM_VERSION = 4 pkg syscall (openbsd-386-cgo), const SIOCBRDGDADDR = 2150132039 @@ -220,6 +235,7 @@ pkg syscall (openbsd-amd64), const EFER_NXE = 2048 pkg syscall (openbsd-amd64), const EFER_NXE ideal-int pkg syscall (openbsd-amd64), const EFER_SCE = 1 pkg syscall (openbsd-amd64), const EFER_SCE ideal-int +pkg syscall (openbsd-amd64), const ImplementsGetwd = false pkg syscall (openbsd-amd64), const PMC5_PIPELINE_FLUSH = 21 pkg syscall (openbsd-amd64), const PMC5_PIPELINE_FLUSH ideal-int pkg syscall (openbsd-amd64), const RTF_FMASK = 63496 @@ -282,6 +298,7 @@ pkg syscall (openbsd-amd64-cgo), const EFER_NXE = 2048 pkg syscall (openbsd-amd64-cgo), const EFER_NXE ideal-int pkg syscall (openbsd-amd64-cgo), const EFER_SCE = 1 pkg syscall (openbsd-amd64-cgo), const EFER_SCE ideal-int +pkg syscall (openbsd-amd64-cgo), const ImplementsGetwd = false pkg syscall (openbsd-amd64-cgo), const PMC5_PIPELINE_FLUSH = 21 pkg syscall (openbsd-amd64-cgo), const PMC5_PIPELINE_FLUSH ideal-int pkg syscall (openbsd-amd64-cgo), const RTF_FMASK = 63496 @@ -345,3 +362,24 @@ pkg syscall (openbsd-386-cgo), const SYS_KILL = 37 pkg syscall (openbsd-amd64), const SYS_KILL = 37 pkg syscall (openbsd-amd64-cgo), const SYS_KILL = 37 pkg unicode, const Version = "9.0.0" +pkg text/template/parse, method (*VariableNode) Copy() Node +pkg text/template/parse, method (*VariableNode) String() string +pkg text/template/parse, method (VariableNode) Position() Pos +pkg text/template/parse, method (VariableNode) Type() NodeType +pkg text/template/parse, type PipeNode struct, Decl []*VariableNode +pkg text/template/parse, type VariableNode struct +pkg text/template/parse, type VariableNode struct, Ident []string +pkg text/template/parse, type VariableNode struct, embedded NodeType +pkg text/template/parse, type VariableNode struct, embedded Pos +pkg syscall (windows-386), type CertChainPolicyPara struct, ExtraPolicyPara uintptr +pkg syscall (windows-386), type CertChainPolicyStatus struct, ExtraPolicyStatus uintptr +pkg syscall (windows-386), type CertContext struct, CertInfo uintptr +pkg syscall (windows-386), type CertRevocationInfo struct, CrlInfo uintptr +pkg syscall (windows-386), type CertRevocationInfo struct, OidSpecificInfo uintptr +pkg syscall (windows-386), type CertSimpleChain struct, TrustListInfo uintptr +pkg syscall (windows-amd64), type CertChainPolicyPara struct, ExtraPolicyPara uintptr +pkg syscall (windows-amd64), type CertChainPolicyStatus struct, ExtraPolicyStatus uintptr +pkg syscall (windows-amd64), type CertContext struct, CertInfo uintptr +pkg syscall (windows-amd64), type CertRevocationInfo struct, CrlInfo uintptr +pkg syscall (windows-amd64), type CertRevocationInfo struct, OidSpecificInfo uintptr +pkg syscall (windows-amd64), type CertSimpleChain struct, TrustListInfo uintptr diff --git a/api/go1.10.txt b/api/go1.10.txt index c8e504c9927..250c10f6abe 100644 --- a/api/go1.10.txt +++ b/api/go1.10.txt @@ -573,6 +573,7 @@ pkg encoding/xml, type TokenReader interface, Token() (Token, error) pkg flag, method (*FlagSet) ErrorHandling() ErrorHandling pkg flag, method (*FlagSet) Name() string pkg flag, method (*FlagSet) Output() io.Writer +pkg html/template, type Srcset string pkg math, func Erfcinv(float64) float64 pkg math, func Erfinv(float64) float64 pkg math, func Round(float64) float64 @@ -594,7 +595,6 @@ pkg os, method (*SyscallError) Timeout() bool pkg os, var ErrNoDeadline error pkg strings, method (*Builder) Grow(int) pkg strings, method (*Builder) Len() int -pkg strings, method (*Builder) ReadFrom(io.Reader) (int64, error) pkg strings, method (*Builder) Reset() pkg strings, method (*Builder) String() string pkg strings, method (*Builder) Write([]uint8) (int, error) @@ -618,24 +618,6 @@ pkg syscall (windows-386), func CreateProcessAsUser(Token, *uint16, *uint16, *Se pkg syscall (windows-386), type SysProcAttr struct, Token Token pkg syscall (windows-amd64), func CreateProcessAsUser(Token, *uint16, *uint16, *SecurityAttributes, *SecurityAttributes, bool, uint32, *uint16, *uint16, *StartupInfo, *ProcessInformation) error pkg syscall (windows-amd64), type SysProcAttr struct, Token Token -pkg text/template/parse, const NodeBreak = 20 -pkg text/template/parse, const NodeBreak NodeType -pkg text/template/parse, const NodeContinue = 21 -pkg text/template/parse, const NodeContinue NodeType -pkg text/template/parse, method (*BreakNode) Copy() Node -pkg text/template/parse, method (*BreakNode) Position() Pos -pkg text/template/parse, method (*BreakNode) String() string -pkg text/template/parse, method (*BreakNode) Type() NodeType -pkg text/template/parse, method (*ContinueNode) Copy() Node -pkg text/template/parse, method (*ContinueNode) Position() Pos -pkg text/template/parse, method (*ContinueNode) String() string -pkg text/template/parse, method (*ContinueNode) Type() NodeType -pkg text/template/parse, type BreakNode struct -pkg text/template/parse, type BreakNode struct, embedded NodeType -pkg text/template/parse, type BreakNode struct, embedded Pos -pkg text/template/parse, type ContinueNode struct -pkg text/template/parse, type ContinueNode struct, embedded NodeType -pkg text/template/parse, type ContinueNode struct, embedded Pos pkg time, func LoadLocationFromTZData(string, []uint8) (*Location, error) pkg unicode, const Version = "10.0.0" pkg unicode, var Masaram_Gondi *RangeTable diff --git a/doc/articles/go_command.html b/doc/articles/go_command.html index 0fd83cb53ab..9f4e8e06316 100644 --- a/doc/articles/go_command.html +++ b/doc/articles/go_command.html @@ -134,7 +134,7 @@ be able to adapt to changing build environments and conditions. For example, if we allowed extra configuration such as compiler flags or command line recipes, then that configuration would need to be updated each time the build tools changed; it would also be inherently tied -to the use of a specific tool chain.

+to the use of a specific toolchain.

Getting started with the go command

diff --git a/doc/articles/wiki/index.html b/doc/articles/wiki/index.html index 3e0d532d7f7..b7ab2cc622f 100644 --- a/doc/articles/wiki/index.html +++ b/doc/articles/wiki/index.html @@ -268,6 +268,12 @@ view a wiki page. It will handle URLs prefixed with "/view/". {{code "doc/articles/wiki/part2.go" `/^func viewHandler/` `/^}/`}} +

+Again, note the use of _ to ignore the error +return value from loadPage. This is done here for simplicity +and generally considered bad practice. We will attend to this later. +

+

First, this function extracts the page title from r.URL.Path, the path component of the request URL. @@ -282,12 +288,6 @@ The function then loads the page data, formats the page with a string of simple HTML, and writes it to w, the http.ResponseWriter.

-

-Again, note the use of _ to ignore the error -return value from loadPage. This is done here for simplicity -and generally considered bad practice. We will attend to this later. -

-

To use this handler, we rewrite our main function to initialize http using the viewHandler to handle diff --git a/doc/asm.html b/doc/asm.html index e3e17f85f58..f2f8fad5766 100644 --- a/doc/asm.html +++ b/doc/asm.html @@ -29,7 +29,7 @@ Instead, the compiler operates on a kind of semi-abstract instruction set, and instruction selection occurs partly after code generation. The assembler works on the semi-abstract form, so when you see an instruction like MOV -what the tool chain actually generates for that operation might +what the toolchain actually generates for that operation might not be a move instruction at all, perhaps a clear or load. Or it might correspond exactly to the machine instruction with that name. In general, machine-specific operations tend to appear as themselves, while more general concepts like @@ -139,7 +139,7 @@ The exact set depends on the architecture.

There are four predeclared symbols that refer to pseudo-registers. These are not real registers, but rather virtual registers maintained by -the tool chain, such as a frame pointer. +the toolchain, such as a frame pointer. The set of pseudo-registers is the same for all architectures:

@@ -738,6 +738,13 @@ The other codes are -> (arithmetic right shift), The ARM64 port is in an experimental state.

+

+R18 is the "platform register", reserved on the Apple platform. +R27 and R28 are reserved by the compiler and linker. +R29 is the frame pointer. +R30 is the link register. +

+

Instruction modifiers are appended to the instruction following a period. The only modifiers are P (postincrement) and W @@ -752,11 +759,61 @@ Addressing modes:

  • -(R5, R6): Register pair for LDP/STP. +R0->16 +
    +R0>>16 +
    +R0<<16 +
    +R0@>16: +These are the same as on the 32-bit ARM. +
  • + +
  • +$(8<<12): +Left shift the immediate value 8 by 12 bits. +
  • + +
  • +8(R0): +Add the value of R0 and 8. +
  • + +
  • +(R2)(R0): +The location at R0 plus R2. +
  • + +
  • +R0.UXTB +
    +R0.UXTB<<imm: +UXTB: extract an 8-bit value from the low-order bits of R0 and zero-extend it to the size of R0. +R0.UXTB<<imm: left shift the result of R0.UXTB by imm bits. +The imm value can be 0, 1, 2, 3, or 4. +The other extensions include UXTH (16-bit), UXTW (32-bit), and UXTX (64-bit). +
  • + +
  • +R0.SXTB +
    +R0.SXTB<<imm: +SXTB: extract an 8-bit value from the low-order bits of R0 and sign-extend it to the size of R0. +R0.SXTB<<imm: left shift the result of R0.SXTB by imm bits. +The imm value can be 0, 1, 2, 3, or 4. +The other extensions include SXTH (16-bit), SXTW (32-bit), and SXTX (64-bit). +
  • + +
  • +(R5, R6): Register pair for LDAXP/LDP/LDXP/STLXP/STP/STP.
+

+Reference: Go ARM64 Assembly Instructions Reference Manual +

+

64-bit PowerPC, a.k.a. ppc64

@@ -882,6 +939,12 @@ The value of GOMIPS environment variable (hardfloat or GOMIPS_hardfloat or GOMIPS_softfloat.

+

+The value of GOMIPS64 environment variable (hardfloat or +softfloat) is made available to assembly code by predefining either +GOMIPS64_hardfloat or GOMIPS64_softfloat. +

+

Unsupported opcodes

diff --git a/doc/conduct.html b/doc/conduct.html index c40b0074f21..bf52ef9fd56 100644 --- a/doc/conduct.html +++ b/doc/conduct.html @@ -183,7 +183,6 @@ satisfaction of all parties. They are:

  • Aditya Mukerjee <dev@chimeracoder.net>
  • Andrew Gerrand <adg@golang.org>
  • Peggy Li <peggyli.224@gmail.com> -
  • Sarah Adams <sadams.codes@gmail.com>
  • Steve Francia <steve.francia@gmail.com>
  • Verónica López <gveronicalg@gmail.com> diff --git a/doc/contrib.html b/doc/contrib.html index 2dc1e7d0e47..df53d480d38 100644 --- a/doc/contrib.html +++ b/doc/contrib.html @@ -118,6 +118,6 @@ guidelines for information on design, testing, and our code review process.

    Check the tracker for open issues that interest you. Those labeled -helpwanted +help wanted are particularly in need of outside help.

    diff --git a/doc/contribute.html b/doc/contribute.html index feeaf086436..d802bd72a16 100644 --- a/doc/contribute.html +++ b/doc/contribute.html @@ -3,39 +3,65 @@ }-->

    -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. +The Go project welcomes all contributors.

    -(Note that the gccgo frontend lives elsewhere; -see Contributing to gccgo.) +This document is a guide to help you through the process +of contributing to the Go project, which is a little different +from that used by other open source projects. +We assume you have a basic understanding of Git and Go.

    -Sensitive security-related issues should be reported to security@golang.org. +In addition to the information here, the Go community maintains a +CodeReview wiki page. +Feel free to contribute to the wiki as you learn the review process.

    -

    Becoming a contributor

    -

    -Before you can contribute to the Go project you need to setup a few prerequisites. -The Go project uses Gerrit, 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 prior to contributing. -You only need to do this once per Google Account. +Note that the gccgo front end lives elsewhere; +see Contributing to gccgo.

    -

    Automatically set up & diagnose your development environment

    +

    Becoming a contributor

    + +

    Overview

    +

    - The go-contrib-init 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: +The first step is registering as a Go contributor and configuring your environment. +Here is a checklist of the required steps to follow: +

    + +
      +
    • +Step 0: Decide on a single Google Account you will be using to contribute to Go. +Use that account for all the following steps and make sure that git +is configured to create commits with that account's e-mail address. +
    • +
    • +Step 1: Sign and submit a +CLA (Contributor License Agreement). +
    • +
    • +Step 2: Configure authentication credentials for the Go Git repository. +Visit go.googlesource.com, click +on "Generate Password" (top right), and follow the instructions. +
    • +
    • +Step 3: Register for Gerrit, the code review tool used by the Go team, +by visiting this page. +The CLA and the registration need to be done only once for your account. +
    • +
    • +Step 4: Install git-codereview by running +go get -u golang.org/x/review/git-codereview +
    • +
    + +

    +If you prefer, there is an automated tool that walks through these steps. +Just run:

    @@ -45,66 +71,61 @@ $ go-contrib-init
     

    - The tool will either set things up, tell you that everything is - configured, or tell you what steps you need to do manually. +The rest of this chapter elaborates on these instructions. +If you have completed the steps above (either manually or through the tool), jump to +Making a change.

    -

    Configure Git to use Gerrit

    +

    Step 0: Select a Google Account

    +

    -You'll need a web browser and a command line terminal. -You should already have Git installed. +A contribution to Go is made through a Google account with a specific +e-mail address. +Make sure to use the same account throughout the process and +for all your subsequent contributions. +You may need to decide whether to use a personal address or a corporate address. +The choice will depend on who +will own the copyright for the code that you will be writing +and submitting. +You might want to discuss this topic with your employer before deciding which +account to use.

    -Gerrit uses Google Accounts for authentication. -If you don't have a Google Account, you can create an account which -includes -a new Gmail email account or create an account associated +Google accounts can either be Gmail e-mail accounts, G-Suite organization accounts, or +accounts associated with an external e-mail address. +For instance, if you need to use +an existing corporate e-mail that is not managed through G-Suite, you can create +an account associated with your existing -email address. -

    - -

    Step 1: Sign in to googlesource and generate a password

    - -

    -Visit go.googlesource.com -and click on "Generate Password" in the page's top right menu bar. -You will be redirected to accounts.google.com to sign in. -

    - -

    Step 2: Run the provided script

    -

    -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. +e-mail address.

    -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.) +You also need to make sure that your Git tool is configured to create commits +using your chosen e-mail address. +You can either configure Git globally +(as a default for all projects), or locally (for a single specific project). +You can check the current configuration with this command:

    +
    +$ git config --global user.email  # check current global config
    +$ git config user.email           # check current local config
    +
    +

    -Your secret authentication token is now in a .gitcookies file -and Git is configured to use this file. +To change the configured address:

    -

    Step 3: Register with Gerrit

    +
    +$ git config --global user.email name@example.com   # change global config
    +$ git config user.email name@example.com            # change local config
    +
    -

    -Now that you have your authentication token, you need to register your -account with Gerrit. -To do this, visit -go-review.googlesource.com/login/. -Sign in using the same Google Account you used above. -

    -

    Contributor License Agreement

    +

    Step 1: Contributor License Agreement

    -

    Which CLA

    Before sending your first change to the Go project you must have completed one of the following two CLAs. @@ -126,42 +147,77 @@ contributor license agreement.

    -If the copyright holder for your contribution has already completed the +You can check your currently signed agreements and sign new ones at +the Google Developers +Contributor License Agreements website. +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. -

    - -

    Completing the CLA

    - -

    -You can see your currently signed agreements and sign new ones through the Gerrit -interface. -To do this, Log into Gerrit, -then visit the Agreements -page. -If you do not have a signed agreement listed there, you can create one -by clicking "New Contributor Agreement" and following the steps. +it does not need to be completed again.

    -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 golang-dev and let us know, so that we can make sure an appropriate agreement is +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 mail +to the golang-dev +mailing list. +This will let us know the situation so we can make sure an appropriate agreement is completed and update the AUTHORS file.

    - -

    Preparing a Development Environment for Contributing

    -

    Setting up Git for submission to Gerrit

    +

    Step 2: Configure git authentication

    +

    -Changes to Go must be reviewed before they are accepted, no matter who makes the change. -A custom git command called git-codereview, discussed below, -helps manage the code review process through a Google-hosted -instance of Gerrit. +Go development happens on +go.googlesource.com, +a Git server hosted by Google. +Authentication on the web server is made through your Google account, but +you also need to configure git on your computer to access it. +Follow this steps: +

    + +
      +
    1. +Visit go.googlesource.com +and click on "Generate Password" in the page's top right menu bar. +You will be redirected to accounts.google.com to sign in. +
    2. +
    3. +After signing in, you will be taken to a page with the title "Configure Git". +This page contains a personalized script that when run locally will configure Git +to hold your unique authentication key. +This key is paired with one that is generated and stored on the server, +analogous to how SSH keys work. +
    4. +
    5. +Copy and run this script locally in your command line terminal to store your +secret authentication token in a .gitcookies file. +If you are using a Windows computer and running cmd, +you should instead follow the instructions in the yellow box to run the command; +otherwise run the regular script. +
    6. +
    + +

    Step 3: Create a Gerrit account

    + +

    +Gerrit is an open-source tool used by Go maintainers to discuss and review +code submissions. +

    + +

    +To register your account, visit +go-review.googlesource.com/login/ and sign in once using the same Google Account you used above. +

    + +

    Step 4: Install the git-codereview command

    + +

    +Changes to Go must be reviewed before they are accepted, no matter who makes the change. +A custom git command called git-codereview +simplifies sending changes to Gerrit.

    -

    Install the git-codereview command

    Install the git-codereview command by running,

    @@ -172,7 +228,8 @@ $ go get -u golang.org/x/review/git-codereview

    Make sure git-codereview is installed in your shell path, so that the -git command can find it. Check that +git command can find it. +Check that

    @@ -185,29 +242,893 @@ prints help text, not an error.
     
     

    On Windows, when using git-bash you must make sure that -git-codereview.exe is in your git exec-path. +git-codereview.exe is in your git exec-path. Run git --exec-path to discover the right location then create a -symbolic link or simply copy the executable from $GOPATH/bin to this directory. +symbolic link or just copy the executable from $GOPATH/bin to this directory. +

    + + +

    Before contributing code

    + +

    +The project welcomes submissions but to make sure things are well +coordinated we ask that everyone to discuss any significant changes to the +Go repositories before starting work. +Best practice is to connect your work to the issue tracker, +either by filing a new issue +or by claiming an existing issue. +

    + +

    Check the issue tracker

    + +

    +Whether you already know what contribution to make, or you are searching for +an idea, the issue tracker is +always the first place to go. +Issues are triaged to categorize them and manage the workflow.

    -Note to Git aficionados: -The git-codereview 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. +Most issues will be marked with one of the following workflow labels: +

    + +
      +
    • + NeedsInvestigation: The issue is not fully understood + and requires analysis to understand the root cause. +
    • +
    • + NeedsDecision: the issue is relatively well understood, but the + Go team hasn't yet decided the best way to address it. + It would be better to wait for a decision before writing code. + If you are interested on working on an issue in this state, + feel free to "ping" maintainers in the issue's comments + if some time has passed without a decision. +
    • +
    • + NeedsFix: the issue is fully understood and code can be written + to fix it. +
    • +
    + +

    Open an issue for any new problem

    + +

    +Excluding very trivial changes, all contributions should be connected +to an existing issue. +Feel free to open one and discuss your plans. +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.

    -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 -Change-Id 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 -git-codereview hooks. +When planning work, please note that the Go project follows a six-month development cycle. +The latter half of each cycle is a three-month feature freeze during +which only bug fixes and documentation updates are accepted. +New contributions can be +sent during a feature freeze but will not be accepted until the freeze is over.

    +

    +Changes in general other than bug and documentation fixes +must go through the +change proposal process +before they can be accepted. +

    + +

    +Sensitive security-related issues (only!) should be reported to security@golang.org. +

    + +

    Sending a change via GitHub

    + +

    +First-time contributors that are already familiar with the +GitHub flow +are encouraged to use the same process for Go contributions. +Even though Go +maintainers use Gerrit for code review, a bot called Gopherbot has been created to sync +GitHub pull requests to Gerrit. +

    + +

    +Open a pull request as you normally would. +Gopherbot will automatically +sync the code and post a link to Gerrit. +When somebody comments on the +change, it will be posted in the pull request, so you will also get a notification. +

    + +

    +Some things to keep in mind: +

    + +
      +
    • +To update the pull request with new code, just push it to the branch; you can either +add more commits, or rebase and force-push (both styles are accepted). +
    • +
    • +If the request is accepted, all commits will be squashed, and the final +commit description will be composed by concatenating the pull request's +title and description. +The individual commits' descriptions will be discarded. +See Writing good commit messages for some +suggestions. +
    • +
    • +Gopherbot is unable to sync line-by-line codereview into GitHub: only the +contents of the overall comment on the request will be synced. +Remember you can always visit Gerrit to see the fine-grained review. +
    • +
    + +

    Sending a change via Gerrit

    + +

    +It is not possible to fully sync Gerrit and GitHub, at least at the moment, +so we recommend learning Gerrit. +It's different but powerful and familiarity +with help you understand the flow. +

    + +

    Overview

    + +

    +This is an overview of the overall process: +

    + +
      +
    • +Step 1: Clone the Go source code from GitHub or go.googlesource.com +and make sure it's stable by compiling and testing it once: +
      +$ git clone https://github.com/golang/go    # or https://go.googlesource.com/go
      +$ cd go/src
      +$ ./all.bash                                # compile and test
      +
      +
    • + +
    • +Step 2: Prepare changes in a new branch, created from the master branch. +To commit the changes, use git codereview change; that +will create or amend a single commit in the branch. +
      +$ git checkout -b mybranch
      +$ [edit files...]
      +$ git add [files...]
      +$ git codereview change   # create commit in the branch
      +$ [edit again...]
      +$ git add [files...]
      +$ git codereview change   # amend the existing commit with new changes
      +$ [etc.]
      +
      +
    • + +
    • +Step 3: Test your changes, re-running all.bash. +
      +$ ./all.bash    # recompile and test
      +
      +
    • + +
    • +Step 4: Send the changes for review to Gerrit using git +codereview mail(which doesn't use e-mail, despite the name). +
      +$ git codereview mail     # send changes to Gerrit
      +
      +
    • + +
    • +Step 5: After a review, apply changes to the same single commit +and mail them to Gerrit again: +
      +$ [edit files...]
      +$ git add [files...]
      +$ git codereview change   # update same commit
      +$ git codereview mail     # send to Gerrit again
      +
      +
    • +
    + +

    +The rest of this section describes these steps in more detail. +

    + + +

    Step 1: Clone the Go source code

    + +

    +In addition to a recent Go installation, you need to have a local copy of the source +checked out from the correct repository. +You can check out the Go source repo onto your local file system anywhere +you want as long as it's outside your GOPATH. +Either clone from +go.googlesource.com or from GitHub: +

    + +
    +$ git clone https://github.com/golang/go   # or https://go.googlesource.com/go
    +$ cd go
    +
    + +

    Step 2: Prepare changes in a new branch

    + +

    +Each Go change must be made in a separate branch, created from the master branch. +You can use +the normal git commands to create a branch and add changes to the +staging area: +

    + +
    +$ git checkout -b mybranch
    +$ [edit files...]
    +$ git add [files...]
    +
    + +

    +To commit changes, instead of git commit, use git codereview change. +

    + +
    +$ git codereview change
    +(open $EDITOR)
    +
    + +

    +You can edit the commit description in your favorite editor as usual. +The git codereview change command +will automatically add a unique Change-Id line near the bottom. +That line is used by Gerrit to match successive uploads of the same change. +Do not edit or delete it. +A Change-Id looks like this: +

    + +
    +Change-Id: I2fbdbffb3aab626c4b6f56348861b7909e3e8990
    +
    + +

    +The tool also checks that you've +run go fmt over the source code, and that +the commit message follows the suggested format. +

    + +

    +If you need to edit the files again, you can stage the new changes and +re-run git codereview change: each subsequent +run will amend the existing commit while preserving the Change-Id. +

    + +

    +Make sure that you always keep a single commit in each branch. +If you add more +commits by mistake, you can use git rebase to +squash them together +into a single one. +

    + + +

    Step 3: Test your changes

    + +

    +You've written and tested your code, 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: +

    + +
    +$ cd go/src
    +$ ./all.bash
    +
    + +

    +(To build under Windows use all.bat; this also requires +setting the environment variable GOROOT_BOOTSTRAP to the +directory holding the Go tree for the bootstrap compiler.) +

    + +

    +After running for a while and printing a lot of testing output, the command should finish +by printing, +

    + +
    +ALL TESTS PASSED
    +
    + +

    +You can use make.bash instead of all.bash +to just build the compiler and standard packages without running the test suite. +Once the go tool is built, it will be installed as bin/go +under the directory in which you cloned the Go repository, and you can +run it directly from there. +See also +the section on how to test your changes quickly. +

    + +

    Step 4: Send changes for review

    + +

    +Once the change is ready and tested over the whole tree, send it for review. +This is done with the mail sub-command which, despite its name, doesn't +directly mail anything; it just sends the change to Gerrit: +

    + +
    +$ git codereview mail
    +
    + +

    +Gerrit assigns your change a number and URL, which git codereview mail will print, something like: +

    + +
    +remote: New Changes:
    +remote:   https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments
    +
    + +

    +If you get an error instead, check the +Troubleshooting mail errors section. +

    + +

    +If your change relates to an open GitHub issue and you have followed the +suggested commit message format, the issue will be updated in a few minutes by a bot, +linking your Gerrit change to it in the comments. +

    + + +

    Step 5: Revise changes after a review

    + +

    +Go maintainers will review your code on Gerrit, and you will get notifications via e-mail. +You can see the review on Gerrit and comment on them there. +You can also reply +using e-mail +if you prefer. +

    + +

    +If you need to revise your change after the review, edit the files in correct branch, +add them to the Git staging area, and then amend the commit with +git codereview change: +

    + +
    +$ git codereview change     # amend current commit
    +(open $EDITOR)
    +$ git codereview mail       # send new changes to Gerrit
    +
    + +

    +If you don't need to change the commit description, just save and exit from the editor. +Remember not to touch the special Change-Id line. +

    + +

    +Again, make sure that you always keep a single commit in each branch. +If you add more +commits by mistake, you can use git rebase to +squash them together +into a single one. +

    + +

    Good commit messages

    + +

    +Commit messages in Go follow a specific set of conventions, +which we discuss in this section. +

    + +

    +Here is an example of a good one: +

    + +
    +math: improve Sin, Cos and Tan precision for very large arguments
    +
    +The existing implementation has poor numerical properties for
    +large arguments, so use the McGillicutty algorithm to improve
    +accuracy above 1e10.
    +
    +The algorithm is described at http://wikipedia.org/wiki/McGillicutty_Algorithm
    +
    +Fixes #159
    +
    + +

    First line

    + +

    +The first line of the change description is conventionally a short one-line +summary of the change, prefixed by the primary affected package. +

    + +

    +A rule of thumb is that it should be written so to complete the sentence +"This change modifies Go to _____." +That means it does not start with a capital letter, is not a complete sentence, +and actually summarizes the result of the change. +

    + +

    +Follow the first line by a blank line. +

    + +

    Main content

    + +

    +The rest of the description elaborates and should provide context for the +change and explain what it does. +Write in complete sentences with correct punctuation, just like +for your comments in Go. +Don't use HTML, Markdown, or any other markup language. +

    + +

    +Add any relevant information, such as benchmark data if the change +afects performance. +The benchcmp +tool is conventionally used to format +benchmark data for change descriptions. +

    + +

    Referencing issues

    + +

    +The special notation "Fixes #12345" associates the change with issue 12345 in the +Go issue tracker. +When this change is eventually applied, the issue +tracker will automatically mark the issue as fixed. +

    + +

    +If the change is a partial step towards the resolution of the issue, +uses the notation "Updates #12345". +This will leave a comment in the issue +linking back to the change in Gerrit, but it will not close the issue +when the change is applied. +

    + +

    +If you are sending a change against a subrepository, you must use +the fully-qualified syntax supported by GitHub to make sure the change is +linked to the issue in the main repository, not the subrepository. +All issues are tracked in the main repository's issue tracker. +The correct form is "Fixes golang/go#159". +

    + + +

    The review process

    + +

    +This section explains the review process in detail and how to approach +reviews after a change has been mailed. +

    + + +

    Common beginner mistakes

    + +

    +When a change is sent to Gerrit, it is usually triaged within a few days. +A maintainer will have a look and provide some initial review that for first-time +contributors usually focuses on basic cosmetics and common mistakes. +These include things like: +

    + +
      +
    • +Commit message not following the suggested +format. +
    • + +
    • +The lack of a linked GitHub issue. +The vast majority of changes +require a linked issue that describes the bug or the feature that the change +fixes or implements, and consensus should have been reached on the tracker +before proceeding with it. +Gerrit reviews do not discuss the merit of the change, +just its implementation. +
      +Only trivial or cosmetic changes will be accepted without an associated issue. +
    • + +
    • +Change sent during the freeze phase of the development cycle, when the tree +is closed for general changes. +In this case, +a maintainer might review the code with a line such as R=go1.12, +which means that it will be reviewed later when the tree opens for a new +development window. +You can add R=go1.XX as a comment yourself +if you know that it's not the correct time frame for the change. +
    • +
    + +

    Trybots

    + +

    +After an initial reading of your change, maintainers will trigger trybots, +a cluster of servers that will run the full test suite on several different +architectures. +Most trybots complete in a few minutes, at which point a link will +be posted in Gerrit where you can see the results. +

    + +

    +If the trybot run fails, follow the link and check the full logs of the +platforms on which the tests failed. +Try to understand what broke, update your patch to fix it, and upload again. +Maintainers will trigger a new trybot run to see +if the problem was fixed. +

    + +

    +Sometimes, the tree can be broken on some platforms for a few hours; if +the failure reported by the trybot doesn't seem related to your patch, go to the +Build Dashboard and check if the same +failure appears in other recent commits on the same platform. +In this case, +feel free to write a comment in Gerrit to mention that the failure is +unrelated to your change, to help maintainers understand the situation. +

    + +

    Reviews

    + +

    +The Go community values very thorough reviews. +Think of each review comment like a ticket: you are expected to somehow "close" it +by acting on it, either by implementing the suggestion or convincing the +reviewer otherwise. +

    + +

    +After you update the change, go through the review comments and make sure +to reply to every one. +You can click the "Done" button to reply +indicating that you've implemented the reviewer's suggestion; otherwise, +click on "Reply" and explain why you have not, or what you have done instead. +

    + +

    +It is perfectly normal for changes to go through several round of reviews, +with one or more reviewers making new comments every time +and then waiting for an updated change before reviewing again. +This cycle happens even for experienced contributors, so +don't be discouraged by it. +

    + +

    Voting conventions

    + +

    +As they near a decision, reviewers will make a "vote" on your change. +The Gerrit voting system involves an integer in the range -2 to +2: +

    + +
      +
    • + +2 The change is approved for being merged. + Only Go maintainers can cast a +2 vote. +
    • +
    • + +1 The change looks good, but either the reviewer is requesting + minor changes before approving it, or they are not a maintainer and cannot + approve it, but would like to encourage an approval. +
    • +
    • + -1 The change is not good the way it is but might be fixable. + A -1 vote will always have a comment explaining why the change is unacceptable. +
    • +
    • + -2 The change is blocked by a maintainer and cannot be approved. + Again, there will be a comment explaining the decision. +
    • +
    + +

    Submitting an approved change

    + +

    +After the code has been +2'ed, an approver will +apply it to the master branch using the Gerrit user interface. +This is called "submitting the change". +

    + +

    +The two steps (approving and submitting) are separate because in some cases maintainers +may want to approve it but not to submit it right away (for instance, +the tree could be temporarily frozen). +

    + +

    +Submitting a change checks it into the repository. +The change description will include a link to the code review, +which will be updated with a link to the change +in the repository. +Since the method used to integrate the changes is Git's "Cherry Pick", +the commit hashes in the repository will be changed by +the submit operation. +

    + +

    +If your change has been approved for a few days without being +submitted, feel free to write a comment in Gerrit requesting +submission. +

    + + +

    More information

    + +

    +In addition to the information here, the Go community maintains a CodeReview wiki page. +Feel free to contribute to this page as you learn more about the review process. +

    + + + +

    Miscellaneous topics

    + +

    +This section collects a number of other comments that are +outside the issue/edit/code review/submit process itself. +

    + + + + +

    +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 +change log and in the CONTRIBUTORS file and perhaps the AUTHORS file. +These files are automatically generated from the commit logs periodically. +The AUTHORS file defines who “The Go +Authors”—the copyright holders—are. +

    + +

    +New files that you contribute should use the standard copyright header: +

    + +
    +// Copyright 2018 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.
    +
    + +

    +(Use the current year if you're reading this in 2019 or beyond.) +Files in the repository are copyrighted the year they are added. +Do not update the copyright year on files that you change. +

    + + + + +

    Troubleshooting mail errors

    + +

    +The most common way that the git codereview mail +command fails is because the e-mail address in the commit does not match the one +that you used during the registration process. + +
    +If you see something like... +

    + +
    +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.
    +
    + +

    +you need to configure Git for this repository to use the +e-mail address that you registered with. +To change the e-mail address for this doesn't happen again, run: +

    + +
    +$ git config user.email email@address.com
    +
    + +

    +Then change the commit to use this alternative e-mail address with this command: +

    + +
    +$ git commit --amend --author="Author Name <email@address.com>"
    +
    + +

    +Then retry by running: +

    + +
    +$ git codereview mail
    +
    + + +

    Quickly testing your changes

    + +

    +Running all.bash for every single change to the code tree +is burdensome. +Even though it is strongly suggested to run it before +sending a change, during the normal development cycle you may want +to compile and test only the package you are developing. +

    + +
      +
    • +In general, you can run make.bash instead of all.bash +to only rebuild the Go tool chain without running the whole test suite. +Or you +can run run.bash to only run the whole test suite without rebuilding +the tool chain. +You can think of all.bash as make.bash +followed by run.bash. +
    • + +
    • +In this section, we'll call the directory into which you cloned the Go repository $GODIR. +The go tool built by $GODIR/make.bashwill be installed +in $GODIR/bin/goand you +can invoke it to test your code. +For instance, if you +have modified the compiler and you want to test how it affects the +test suite of your own project, just run go test +using it: + +
      +$ cd <MYPROJECTDIR>
      +$ $GODIR/bin/go test
      +
      +
    • + +
    • +If you're changing the standard library, you probably don't need to rebuild +the compiler: you can just run the tests for the package you've changed. +You can do that either with the Go version you normally use, or +with the Go compiler built from your clone (which is +sometimes required because the standard library code you're modifying +might require a newer version than the stable one you have installed). + +
      +$ cd $GODIR/src/hash/sha1
      +$ [make changes...]
      +$ $GODIR/bin/go test .
      +
      +
    • + +
    • +If you're modifying the compiler itself, you can just recompile +the compile tool (which is the internal binary invoked +by go build to compile each single package). +After that, you will want to test it by compiling or running something. + +
      +$ cd $GODIR/src
      +$ [make changes...]
      +$ $GODIR/bin/go install cmd/compile
      +$ $GODIR/bin/go build [something...]   # test the new compiler
      +$ $GODIR/bin/go run [something...]     # test the new compiler
      +$ $GODIR/bin/go test [something...]    # test the new compiler
      +
      + +The same applies to other internal tools of the Go tool chain, +such as asm, cover, link, and so on. +Just recompile and install the tool using go +install cmd/<TOOL> and then use +the built Go binary to test it. +
    • + +
    • +In addition to the standard per-package tests, there is a top-level +test suite in $GODIR/test that contains +several black-box and regression tests. +The test suite is run +by all.bash but you can also run it manually: + +
      +$ cd $GODIR/test
      +$ $GODIR/bin/go run run.go
      +
      +
    + +

    Contributing to subrepositories (golang.org/x/...)

    + +

    +If you are contributing a change to a subrepository, obtain the +Go package using go get. +For example, to contribute +to golang.org/x/oauth2, check out the code by running: +

    + +
    +$ go get -d golang.org/x/oauth2/...
    +
    + +

    +Then, change your directory to the package's source directory +($GOPATH/src/golang.org/x/oauth2), and follow the +normal contribution flow. +

    + + +

    Specifying a reviewer / CCing others

    + +

    +Unless explicitly told otherwise, such as in the discussion leading +up to sending in the change, it's better not to specify a reviewer. +All changes are automatically CC'ed to the +golang-codereviews@googlegroups.com +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. +

    + +

    +You can specify a reviewer or CC interested parties +using the -r or -cc options. +Both accept a comma-separated list of e-mail addresses: +

    + +
    +$ git codereview mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
    +
    + + +

    Synchronize your client

    + +

    +While you were working, others might have submitted changes to the repository. +To update your local branch, run +

    + +
    +$ git codereview sync
    +
    + +

    +(Under the covers this runs +git pull -r.) +

    + + +

    Reviewing code by others

    + +

    +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. +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 will look something like this: +

    + +
    +$ git fetch https://go.googlesource.com/review refs/changes/21/13245/1 && git checkout FETCH_HEAD
    +
    + +

    +To revert, change back to the branch you were working in. +

    + +

    Set up git aliases

    @@ -230,14 +1151,9 @@ $ git sync

    The git-codereview subcommands have been chosen to be distinct from -Git's own, so it's safe to do so. -

    - -

    -The aliases are optional, but in the rest of this document we will assume -they are installed. -To install them, copy this text into your Git configuration file -(usually .gitconfig in your home directory): +Git's own, so it's safe to define these aliases. +To install them, copy this text into your +Git configuration file (usually .gitconfig in your home directory):

    @@ -250,648 +1166,26 @@ To install them, copy this text into your Git configuration file
     	sync = codereview sync
     
    - -

    Understanding the git-codereview command

    -

    After installing the git-codereview command, you can run

    - -
    -$ git codereview help
    -
    +

    Sending multiple dependent changes

    -to learn more about its commands. -You can also read the command documentation. -

    - - -

    Making a Contribution

    - -

    Discuss your design

    - -

    -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. +Advanced users may want to stack up related commits in a single branch. +Gerrit allows for changes to be dependent on each other, forming such a dependency chain. +Each change will need to be approved and submitted separately but the dependency +will be visible to reviewers.

    -Before undertaking to write something new for the Go project, -please file an issue -(or claim an existing issue). -Significant changes must go through the -change proposal process -before they can be accepted. -

    - -

    -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. -

    - -

    -When planning work, please note that the Go project follows a six-month development cycle. -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. -

    - -

    Not sure what change to make?

    - -

    -If you want to become familiar with Gerrit and the contribution process, -but aren't sure what you'd like to contribute just yet, you can use the scratch repository to practice -making a change. -

    - -

    Making a change

    - -

    Getting Go Source

    -

    -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. -

    - -

    -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. +To send out a group of dependent changes, keep each change as a different commit under +the same branch, and then run:

    -$ git clone https://go.googlesource.com/go
    -$ cd go
    -
    - -

    Contributing to the main Go tree

    - -

    -Most Go installations use a release branch, but new changes should -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: -

    - -
    -$ git checkout master
    -$ git sync
    +$ git codereview mail HEAD
     

    -(In Git terms, git sync runs -git pull -r.) -

    - -

    Contributing to subrepositories (golang.org/x/...)

    - -

    -If you are contributing a change to a subrepository, obtain the -Go package using go get. For example, to contribute -to golang.org/x/oauth2, check out the code by running: -

    - -
    -$ go get -d golang.org/x/oauth2/...
    -
    - -

    -Then, change your directory to the package's source directory -($GOPATH/src/golang.org/x/oauth2). -

    - -

    Make your changes

    - -

    -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. -

    - - - -

    -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 -change log and in the CONTRIBUTORS file and perhaps the AUTHORS file. -These files are automatically generated from the commit logs periodically. -The AUTHORS file defines who “The Go -Authors”—the copyright holders—are. -

    - -

    New files that you contribute should use the standard copyright header:

    - -
    -// 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.
    -
    - -

    -Files in the repository are copyright the year they are added. -Do not update the copyright year on files that you change. -

    - -

    Commit your changes

    - -

    -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, -git add, -git rm, -and -git mv. -

    - -

    -Once you have the changes queued up, you will want to commit them. -In the Go contribution workflow this is done with a git -change command, which creates a local branch and commits the changes -directly to that local branch. -

    - -

    -The workflow described here assumes a single change per branch. -It is also possible to prepare a sequence of (usually related) changes in a single branch. -See the git-codereview documentation for details. -

    - -
    -$ git change <branch>
    -
    - -

    -The name <branch> 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. -

    - -

    -(In Git terms, git change <branch> -runs git checkout -b branch, -then git branch --set-upstream-to origin/master, -then git commit.) -

    - -

    -As the git commit is the final step, Git will open an -editor to ask for a commit message. (It uses the editor named by -the $EDITOR environment variable, -vi by default.) - -The file will look like: -

    - -
    -
    -# Please enter the commit message for your changes. Lines starting
    -# with '#' will be ignored, and an empty message aborts the commit.
    -# On branch foo
    -# Changes not staged for commit:
    -#	modified:   editedfile.go
    -#
    -
    - -

    -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. -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. -Write in complete sentences with correct punctuation, just like -for your comments in Go. -If there is a helpful reference, mention it here. -If you've fixed an issue, reference it by number with a # before it. -

    - -

    -After editing, the template might now read: -

    - -
    -math: improve Sin, Cos and Tan precision for very large arguments
    -
    -The existing implementation has poor numerical properties for
    -large arguments, so use the McGillicutty algorithm to improve
    -accuracy above 1e10.
    -
    -The algorithm is described at http://wikipedia.org/wiki/McGillicutty_Algorithm
    -
    -Fixes #159
    -
    -# Please enter the commit message for your changes. Lines starting
    -# with '#' will be ignored, and an empty message aborts the commit.
    -# On branch foo
    -# Changes not staged for commit:
    -#	modified:   editedfile.go
    -#
    -
    - -

    -The commented section of the file lists all the modified files in your client. -It is best to keep unrelated changes in different commits, -so if you see a file listed that should not be included, abort -the command and move that file to a different branch. -

    - -

    -The special notation "Fixes #159" associates the change with issue 159 in the -Go issue tracker. -When this change is eventually applied, the issue -tracker will automatically mark the issue as fixed. -(There are several such conventions, described in detail in the -GitHub Issue Tracker documentation.) -

    - -

    -Once you have finished writing the commit message, -save the file and exit the editor. -

    - -

    -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. -

    - -

    -If you wish to do more editing, re-stage your changes using -git add, and then run -

    - -
    -$ git change
    -
    - -

    -to update the change description and incorporate the staged changes. -The change description contains a Change-Id line near the bottom, -added by a Git commit hook during the initial -git change. -That line is used by Gerrit to match successive uploads of the same change. -Do not edit or delete it. -

    - -

    -(In Git terms, git change with no branch name -runs git commit --amend.) -

    - -

    Testing

    - -

    -You've written and tested your code, 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: -

    - -
    -$ cd go/src
    -$ ./all.bash
    -
    - -

    -(To build under Windows use all.bat.) -

    - -

    -After running for a while, the command should print -

    - -
    -"ALL TESTS PASSED".
    -
    - -

    Send the change for review

    - -

    -Once the change is ready, send it for review. -This is similar to a git push 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. -

    - -
    -$ git mail
    -
    - -

    -(In Git terms, git mail pushes the local committed -changes to Gerrit using git push origin -HEAD:refs/for/master.) -

    - -

    -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. -

    - -

    -The code review server assigns your change an issue number and URL, -which git mail will print, something like: -

    - -
    -remote: New Changes:
    -remote:   https://go-review.googlesource.com/99999 math: improved Sin, Cos and Tan precision for very large arguments
    -
    - -

    Troubleshooting

    - -

    -The most common way that the git mail command fails is because the -email address used has not gone through the setup above. -
    -If you see something like... -

    - -
    -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.
    -
    - -

    -You need to either add the email address listed to the CLA or set this repo to use -another email address already approved. -

    - -

    -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: -

    - -
    -$ git config user.email email@address.com
    -
    - -

    -Then change the previous commit to use this alternative email address. -You can do that with: -

    - -
    -$ git commit --amend --author="Author Name <email@address.com>"
    -
    - -

    -Finally try to resend with: -

    - -
    -$ git mail
    -
    - -

    Specifying a reviewer / CCing others

    - -

    -Unless explicitly told otherwise, such as in the discussion leading -up to sending in the change, it's better not to specify a reviewer. -All changes are automatically CC'ed to the -golang-codereviews@googlegroups.com -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. -

    - -

    -You can specify a reviewer or CC interested parties -using the -r or -cc options. -Both accept a comma-separated list of email addresses: -

    - -
    -$ git mail -r joe@golang.org -cc mabel@example.com,math-nuts@swtch.com
    -
    - -

    Going through the review process

    - -

    -Running git mail will send an email to you and the -reviewers asking them to visit the issue's URL and make comments on the change. -When done, the reviewer adds comments through the Gerrit user interface -and clicks "Reply" to send comments back. -You will receive a mail notification when this happens. -You may reply through the web interface or -via email. -

    - -

    Revise and resend

    - -

    -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. -

    - -

    -You may respond to review comments through the web interface or -via email. -

    - -

    -When you have revised the code and are ready for another round of review, -stage those changes and use git change to update the -commit. -To send the updated change for another round of review, -run git mail again. -

    - -

    -The reviewer can comment on the new copy, and the process repeats. -The reviewer approves the change by giving it a positive score -(+1 or +2) and replying LGTM: looks good to me. -

    - -

    -You can see a list of your pending changes by running git -pending, and switch between change branches with git -change <branch>. -

    - -

    Synchronize your client

    - -

    -While you were working, others might have submitted changes to the repository. -To update your local branch, run -

    - -
    -$ git sync
    -
    - -

    -(In git terms, git sync runs -git pull -r.) -

    - -

    Resolving Conflicts

    - -

    -If files you were editing have changed, Git does its best to merge the -remote changes into your local changes. -It may leave some files to merge by hand. -

    - -

    -For example, suppose you have edited sin.go but -someone else has committed an independent change. -When you run git sync, -you will get the (scary-looking) output: - -

    -$ git sync
    -Failed to merge in the changes.
    -Patch failed at 0023 math: improved Sin, Cos and Tan precision for very large arguments
    -The copy of the patch that failed is found in:
    -   /home/you/repo/.git/rebase-apply/patch
    -
    -When you have resolved this problem, run "git rebase --continue".
    -If you prefer to skip this patch, run "git rebase --skip" instead.
    -To check out the original branch and stop rebasing, run "git rebase --abort".
    -
    - -

    -If this happens, run -

    - -
    -$ git status
    -
    - -

    -to see which files failed to merge. -The output will look something like this: -

    - -
    -rebase in progress; onto a24c3eb
    -You are currently rebasing branch 'mcgillicutty' on 'a24c3eb'.
    -  (fix conflicts and then run "git rebase --continue")
    -  (use "git rebase --skip" to skip this patch)
    -  (use "git rebase --abort" to check out the original branch)
    -
    -Unmerged paths:
    -  (use "git reset HEAD <file>..." to unstage)
    -  (use "git add <file>..." to mark resolution)
    -
    -	both modified: sin.go
    -
    - -

    -The only important part in that transcript is the italicized "both modified" -line: Git failed to merge your changes with the conflicting change. -When this happens, Git leaves both sets of edits in the file, -with conflicts marked by <<<<<<< and ->>>>>>>. -It is now your job to edit the file to combine them. -Continuing the example, searching for those strings in sin.go -might turn up: -

    - -
    -	arg = scale(arg)
    -<<<<<<< HEAD
    -	if arg < 1e9 {
    -=======
    -	if arg < 1e10 {
    ->>>>>>> mcgillicutty
    -		largeReduce(arg)
    -
    - -

    -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: -

    - -
    -	arg = scale(arg)
    -	if arg < 1e10 {
    -		largeReduce(arg)
    -
    - -

    -Then tell Git that the conflict is resolved by running -

    - -
    -$ git add sin.go
    -
    - -

    -If you had been editing the file, say for debugging, but do not -care to preserve your changes, you can run -git reset HEAD sin.go -to abandon your changes. -Then run git rebase --continue to -restore the change commit. -

    - -

    Reviewing code by others

    - -

    -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. -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: -

    - -
    -$ git fetch https://go.googlesource.com/review refs/changes/21/1221/1 && git checkout FETCH_HEAD
    -
    - -

    -To revert, change back to the branch you were working in. -

    - -

    Apply the change to the master branch

    - -

    -After the code has been LGTM'ed, an approver may -apply 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). -

    - -

    -This checks the change into the repository. -The change description will include a link to the code review, -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. -

    - -

    More information

    - -

    -In addition to the information here, the Go community maintains a CodeReview wiki page. -Feel free to contribute to this page as you learn the review process. +Make sure to explicitly specify HEAD, which is usually not required when sending +single changes.

    diff --git a/doc/debugging_with_gdb.html b/doc/debugging_with_gdb.html index 633d058c111..19d36f7d97b 100644 --- a/doc/debugging_with_gdb.html +++ b/doc/debugging_with_gdb.html @@ -3,28 +3,54 @@ "Path": "/doc/gdb" }--> -

    -This applies to the standard toolchain (the gc Go -compiler and tools). Gccgo has native gdb support. -Besides this overview you might want to consult the -GDB manual. -

    + + + +

    +The following instructions apply to the standard toolchain +(the gc Go compiler and tools). +Gccgo has native gdb support. +

    +

    +Note that +Delve is a better +alternative to GDB when debugging Go programs built with the standard +toolchain. It understands the Go runtime, data structures, and +expressions better than GDB. Delve currently supports Linux, OSX, +and Windows on amd64. +For the most up-to-date list of supported platforms, please see + + the Delve documentation. +

    +

    GDB does not understand Go programs well. The stack management, threading, and runtime contain aspects that differ enough from the execution model GDB expects that they can confuse -the debugger, even when the program is compiled with gccgo. -As a consequence, although GDB can be useful in some situations, it is -not a reliable debugger for Go programs, particularly heavily concurrent ones. -Moreover, it is not a priority for the Go project to address these issues, which -are difficult. -In short, the instructions below should be taken only as a guide to how -to use GDB when it works, not as a guarantee of success. +the debugger and cause incorrect results even when the program is +compiled with gccgo. +As a consequence, although GDB can be useful in some situations (e.g., +debugging Cgo code, or debugging the runtime itself), it is not +a reliable debugger for Go programs, particularly heavily concurrent +ones. Moreover, it is not a priority for the Go project to address +these issues, which are difficult. +

    + +

    +In short, the instructions below should be taken only as a guide to how +to use GDB when it works, not as a guarantee of success. + +Besides this overview you might want to consult the +GDB manual.

    -In time, a more Go-centric debugging architecture may be required.

    Introduction

    @@ -38,16 +64,15 @@ use to inspect a live process or a core dump.

    Pass the '-w' flag to the linker to omit the debug information -(for example, go build -ldflags "-w" prog.go). +(for example, go build -ldflags=-w prog.go).

    The code generated by the gc compiler includes inlining of function invocations and registerization of variables. These optimizations -can sometimes make debugging with gdb harder. To disable them -when debugging, pass the flags -gcflags "-N -l" to the -go command used to build the code being -debugged. +can sometimes make debugging with gdb harder. +If you find that you need to disable these optimizations, +build your program using go build -gcflags=all="-N -l".

    @@ -94,7 +119,7 @@ Show the name, type and location of global variables:

    A recent extension mechanism to GDB allows it to load extension scripts for a -given binary. The tool chain uses this to extend GDB with a handful of +given binary. The toolchain uses this to extend GDB with a handful of commands to inspect internals of the runtime code (such as goroutines) and to pretty print the built-in map, slice and channel types.

    @@ -139,7 +164,7 @@ the DWARF code.

    If you're interested in what the debugging information looks like, run -'objdump -W a.out' and browse through the .debug_* +objdump -W a.out and browse through the .debug_* sections.

    @@ -162,7 +187,7 @@ the form pkg.(*MyType).Meth.

    In this tutorial we will inspect the binary of the regexp package's unit tests. To build the binary, -change to $GOROOT/src/regexp and run go test -c. +change to $GOROOT/src/regexp and run go test -c. This should produce an executable file named regexp.test.

    @@ -188,7 +213,7 @@ Loading Go Runtime support.

    -The message "Loading Go Runtime support" means that GDB loaded the +The message "Loading Go Runtime support" means that GDB loaded the extension from $GOROOT/src/runtime/runtime-gdb.py.

    @@ -353,7 +378,7 @@ Stack level 0, frame at 0x7ffff7f9ff88:

    -The command info locals lists all variables local to the function and their values, but is a bit +The command info locals lists all variables local to the function and their values, but is a bit dangerous to use, since it will also try to print uninitialized variables. Uninitialized slices may cause gdb to try to print arbitrary large arrays.

    @@ -386,7 +411,7 @@ $3 = struct hchan<*testing.T>

    -That struct hchan<*testing.T> is the +That struct hchan<*testing.T> is the runtime-internal representation of a channel. It is currently empty, or gdb would have pretty-printed its contents.

    diff --git a/doc/devel/release.html b/doc/devel/release.html index 2e5b0d44ae0..30d1611509d 100644 --- a/doc/devel/release.html +++ b/doc/devel/release.html @@ -16,11 +16,36 @@ git checkout release-branch

    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. +For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was +supported until the Go 1.8 release. We fix critical problems, including critical security problems, in supported releases as needed by issuing minor revisions -(for example, Go 1.9.1, Go 1.9.2, and so on). +(for example, Go 1.6.1, Go 1.6.2, and so on). +

    + +

    go1.10 (released 2018/02/16)

    + +

    +Go 1.10 is a major release of Go. +Read the Go 1.10 Release Notes for more information. +

    + +

    Minor revisions

    + +

    +go1.10.1 (released 2018/03/28) includes fixes to the compiler, runtime, and the +archive/zip, crypto/tls, crypto/x509, +encoding/json, net, net/http, and +net/http/pprof packages. +See the Go +1.10.1 milestone on our issue tracker for details. +

    + +

    +go1.10.2 (released 2018/05/01) includes fixes to the compiler, linker, and go +command. +See the Go +1.10.2 milestone on our issue tracker for details.

    go1.9 (released 2017/08/24)

    @@ -49,6 +74,34 @@ See the Go 1.9.2 milestone on our issue tracker for details.

    +

    +go1.9.3 (released 2018/01/22) includes fixes to the compiler, runtime, +and the database/sql, math/big, net/http, +and net/url packages. +See the Go +1.9.3 milestone on our issue tracker for details. +

    + +

    +go1.9.4 (released 2018/02/07) includes a security fix to “go get”. +See the Go +1.9.4 milestone on our issue tracker for details. +

    + +

    +go1.9.5 (released 2018/03/28) includes fixes to the compiler, go command, and +net/http/pprof package. +See the Go +1.9.5 milestone on our issue tracker for details. +

    + +

    +go1.9.6 (released 2018/05/01) includes fixes to the compiler and go command. +See the Go +1.9.6 milestone on our issue tracker for details. +

    + +

    go1.8 (released 2017/02/16)

    @@ -99,6 +152,20 @@ See the Go 1.8.5 milestone on our issue tracker for details.

    +

    +go1.8.6 (released 2018/01/22) includes the same fix in math/big +as Go 1.9.3 and was released at the same time. +See the Go +1.8.6 milestone on our issue tracker for details. +

    + +

    +go1.8.7 (released 2018/02/07) includes a security fix to “go get”. +It contains the same fix as Go 1.9.4 and was released at the same time. +See the Go +1.8.7 milestone on our issue tracker for details. +

    +

    go1.7 (released 2016/08/15)

    @@ -272,7 +339,7 @@ See the change history

    -go1.3.3 (released 2014/09/30) includes further bug fixes to cgo, the runtime package, and the nacl port. +go1.3.3 (released 2014/09/30) includes further bug fixes to cgo, the runtime package, and the nacl port. See the change history for details.

    @@ -336,7 +403,7 @@ about the future of Go 1.

    -The go1 release corresponds to +The go1 release corresponds to weekly.2012-03-27.

    @@ -352,7 +419,7 @@ It also includes several minor code and documentation fixes.

    go1.0.2 (released 2012/06/13) was issued to fix two bugs in the implementation -of maps using struct or array keys: +of maps using struct or array keys: issue 3695 and issue 3573. It also includes many minor code and documentation fixes. diff --git a/doc/diagnostics.html b/doc/diagnostics.html index 8f5b59ecee7..35aae156e8b 100644 --- a/doc/diagnostics.html +++ b/doc/diagnostics.html @@ -3,6 +3,13 @@ "Template": true }--> + +

    Introduction

    @@ -45,7 +52,7 @@ of code. The Go runtime provides in the format expected by the pprof visualization tool. The profiling data can be collected during testing -via go test or endpoints made available from the +via go test or endpoints made available from the net/http/pprof package. Users need to collect the profiling data and use pprof tools to filter and visualize the top code paths.

    @@ -119,7 +126,7 @@ so it is recommended to collect only a single profile at a time.

    The Go tools provide text, graph, and callgrind -visualization of the profile data via +visualization of the profile data using go tool pprof. Read Profiling Go programs to see them in action. @@ -149,9 +156,11 @@ in the listing.

    -Another way to visualize profile data is a flame graph. +Another way to visualize profile data is a flame graph. Flame graphs allow you to move in a specific ancestry path, so you can zoom -in/out specific sections of code more easily. +in/out of specific sections of code. +The upstream pprof +has support for flame graphs.

    @@ -183,9 +192,19 @@ handler on :7777 at /custom_debug_path/profile:

    -mux := http.NewServeMux()
    -mux.HandleFunc("/custom_debug_path/profile", pprof.Profile)
    -http.ListenAndServe(":7777", mux)
    +package main
    +
    +import (
    +	"log"
    +	"net/http"
    +	"net/http/pprof"
    +)
    +
    +func main() {
    +	mux := http.NewServeMux()
    +	mux.HandleFunc("/custom_debug_path/profile", pprof.Profile)
    +	log.Fatal(http.ListenAndServe(":7777", mux))
    +}
     

    @@ -203,7 +222,7 @@ an execution tracer to trace the runtime events within an interval.

    Tracing enables us to:

      -
    • Instrument and profile application latency in a Go process.
    • +
    • Instrument and analyze application latency in a Go process.
    • Measure the cost of specific calls in a long chain of calls.
    • Figure out the utilization and performance improvements. Bottlenecks are not always obvious without tracing data.
    • @@ -252,7 +271,8 @@ trace spans. You need to manually instrument your code to create, end, and annot

      How should I propagate trace headers in Go libraries?

      -You can propagate trace identifiers and tags in the context.Context. +You can propagate trace identifiers and tags in the +context.Context. There is no canonical trace key or common representation of trace headers in the industry yet. Each tracing provider is responsible for providing propagation utilities in their Go libraries. @@ -265,7 +285,8 @@ runtime can be included in a trace?

      The standard library and runtime are trying to expose several additional APIs -to notify on low level internal events. For example, httptrace.ClientTrace +to notify on low level internal events. For example, +httptrace.ClientTrace provides APIs to follow low-level events in the life cycle of an outgoing request. There is an ongoing effort to retrieve low-level runtime events from the runtime execution tracer and allow users to define and record their user events. @@ -303,25 +324,25 @@ create confusion.

      How well do debuggers work with Go programs?

      -As of Go 1.9, the DWARF info generated by the gc compiler is not complete -and sometimes makes debugging harder. There is an ongoing effort to improve the -DWARF information to help the debuggers display more accurate information. -Until those improvements are in you may prefer to disable compiler -optimizations during development for more accuracy. To disable optimizations, -use the "-N -l" compiler flags. For example, the following command builds -a package with no compiler optimizations: +The gc compiler performs optimizations such as +function inlining and variable registerization. These optimizations +sometimes make debugging with debuggers harder. There is an ongoing +effort to improve the quality of the DWARF information generated for +optimized binaries. Until those improvements are available, we recommend +disabling optimizations when building the code being debugged. The following +command builds a package with no compiler optimizations:

      -$ go build -gcflags="-N -l"
      +$ go build -gcflags=all="-N -l"
       

      -

      -As of Go 1.10, the Go binaries will have the required DWARF information -for accurate debugging. To enable the DWARF improvements, use the following -compiler flags and use GDB until Delve supports location lists: -

      +As part of the improvement effort, Go 1.10 introduced a new compiler +flag -dwarflocationlists. The flag causes the compiler to +add location lists that helps debuggers work with optimized binaries. +The following command builds a package with optimizations but with +the DWARF location lists:

      @@ -333,9 +354,7 @@ $ go build -gcflags="-dwarflocationlists=true"
       
       

      Even though both delve and gdb provides CLIs, most editor integrations -and IDEs provides debugging-specific user interfaces. Please refer to -the editors guide to see the options -with debugger UI support. +and IDEs provides debugging-specific user interfaces.

      Is it possible to do postmortem debugging with Go programs?

      @@ -421,7 +440,7 @@ Use profiling tools instead first to address them.

      fine, and then it became serialized. It suggests that there might be lock contention for a shared resource that creates a bottleneck.

      -

      See go tool trace +

      See go tool trace to collect and analyze runtime traces.

      diff --git a/doc/editors.html b/doc/editors.html index 4a8c7eab6bd..617a1001303 100644 --- a/doc/editors.html +++ b/doc/editors.html @@ -33,199 +33,3 @@ community-maintained list of IDEs and text editor plugins is available at the Wiki.

      - -

      -Each development environment integrates a number of Go-specific tools. -The following feature matrix lists and compares the most significant features. -

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

      vim

      Visual Studio Code

      GoLand

      Atom
      Editing features
      Build and run from the editor/IDEYesYesYesYes
      Autocompletion of identifiers (variable, method, and function names)YesYesYesYes
      Type-aware autocompletionNoNoYesNo
      Rename identifiersYesYesYesYes
      Auto format, build, vet, and lint on saveYesYesYes1Yes
      Auto insert import paths and remove unused on saveYesYesYes2Yes
      Auto generate JSON, XML tags for struct fieldsYesYesYesYes
      Navigation features
      Display documentation inline, or open godoc in browserYesYesYesYes
      Switch between *.go and *_test.go fileYesYesYesNo
      Jump to definition and refereesYesYesYesYes
      Look up for interface implementationsYesYesYesYes
      Search for callers and calleesYesYesYesYes
      Testing and debugging features
      Debugger supportNoYesYesYes3
      Run a single test case, all tests from file, or all tests from a packageYesYesYesNo
      Auto generate tests for packages, files and identifiersNoYesYesNo
      Debug testsNoYesYesYes3
      Display test coverageYesYesYesYes
      InstallInstallInstallInstall
      - -

      -1Possible when enabled via Settings > Go > On Save, go vet and golint are available via plugins. Also runs tests on save if configured. -
      -2Additionally, user input can disambiguate when two or more options are available. -
      -3Available if the go-debug package is installed. -

      - - - - diff --git a/doc/editors/go-plus.png b/doc/editors/go-plus.png deleted file mode 100644 index c09c7fe6756..00000000000 Binary files a/doc/editors/go-plus.png and /dev/null differ diff --git a/doc/editors/goland.png b/doc/editors/goland.png deleted file mode 100644 index 842f089e4ad..00000000000 Binary files a/doc/editors/goland.png and /dev/null differ diff --git a/doc/editors/vimgo.png b/doc/editors/vimgo.png deleted file mode 100644 index cf317eff32f..00000000000 Binary files a/doc/editors/vimgo.png and /dev/null differ diff --git a/doc/editors/vscodego.png b/doc/editors/vscodego.png deleted file mode 100644 index 4e6c7b8047b..00000000000 Binary files a/doc/editors/vscodego.png and /dev/null differ diff --git a/doc/effective_go.html b/doc/effective_go.html index 61de824fcd2..89c1d08782a 100644 --- a/doc/effective_go.html +++ b/doc/effective_go.html @@ -3588,8 +3588,7 @@ That's left as an exercise for the reader.

      Let's finish with a complete Go program, a web server. This one is actually a kind of web re-server. -Google provides a service at -http://chart.apis.google.com +Google provides a service at chart.apis.google.com that does automatic formatting of data into charts and graphs. It's hard to use interactively, though, because you need to put the data into the URL as a query. diff --git a/doc/go1.1.html b/doc/go1.1.html index f059fd7f1f9..f615c97e810 100644 --- a/doc/go1.1.html +++ b/doc/go1.1.html @@ -166,7 +166,7 @@ providing a complete Go 1.1 implementation.

      Command-line flag parsing

      -In the gc tool chain, the compilers and linkers now use the +In the gc toolchain, the compilers and linkers now use the same command-line flag parsing rules as the Go flag package, a departure from the traditional Unix flag parsing. This may affect scripts that invoke the tool directly. @@ -305,7 +305,7 @@ The race detector is documented in a

      Due to the change of the int to 64 bits and a new internal representation of functions, -the arrangement of function arguments on the stack has changed in the gc tool chain. +the arrangement of function arguments on the stack has changed in the gc toolchain. Functions written in assembly will need to be revised at least to adjust frame pointer offsets.

      @@ -395,7 +395,7 @@ Run go help test for more information. The fix command, usually run as go fix, no longer applies fixes to update code from before Go 1 to use Go 1 APIs. -To update pre-Go 1 code to Go 1.1, use a Go 1.0 tool chain +To update pre-Go 1 code to Go 1.1, use a Go 1.0 toolchain to convert the code to Go 1.0 first.

      @@ -427,7 +427,7 @@ To build a file only with Go 1.0.x, use the converse constraint:

      Additional platforms

      -The Go 1.1 tool chain adds experimental support for freebsd/arm, +The Go 1.1 toolchain adds experimental support for freebsd/arm, netbsd/386, netbsd/amd64, netbsd/arm, openbsd/386 and openbsd/amd64 platforms.

      diff --git a/doc/go1.10.html b/doc/go1.10.html index c744fa511fc..2974fef9a3a 100644 --- a/doc/go1.10.html +++ b/doc/go1.10.html @@ -15,34 +15,37 @@ Do not send CLs removing the interior tags from such phrases. ul li { margin: 0.5em 0; } -

      DRAFT RELEASE NOTES - Introduction to Go 1.10

      - -

      - Go 1.10 is not yet released. These are work-in-progress - release notes. Go 1.10 is expected to be released in February 2018. -

      +

      Introduction to Go 1.10

      -The latest Go release, version 1.10, arrives six months after go1.9. +The latest Go release, version 1.10, arrives six months after Go 1.9. Most of its changes are in the implementation of the toolchain, runtime, and libraries. As always, the release maintains the Go 1 promise of compatibility. We expect almost all Go programs to continue to compile and run as before.

      -OVERVIEW HERE +This release improves caching of built packages, +adds caching of successful test results, +runs vet automatically during tests, +and +permits passing string values directly between Go and C using cgo. +A new compiler option whitelist may cause +unexpected invalid +flag errors in code that built successfully with older +releases.

      Changes to the language

      -There are no substantive changes to the language. +There are no significant changes to the language specification.

      -A corner case involving shifts by untyped constants has been clarified, +A corner case involving shifts of untyped constants has been clarified, and as a result the compilers have been updated to allow the index expression -x[1.0 << s] where s is an untyped constant; +x[1.0 << s] where s is an unsigned integer; the go/types package already did.

      @@ -64,11 +67,6 @@ in particular new instructions in the assembler and improvements to the code generated by the compilers.

      -

      -Go 1.10 is the last release that will run on OS X 10.8 Mountain Lion. -Go 1.11 will require OS X 10.9 Mavericks or later. -

      -

      As announced in the Go 1.9 release notes, Go 1.10 now requires FreeBSD 10.3 or later; @@ -76,15 +74,9 @@ support for FreeBSD 9.3 has been removed.

      -Go now runs on NetBSD again, but requires the unreleased NetBSD 8. -Only GOARCH=amd64 running on NetBSD amd64 and GOARCH=386 -running on NetBSD i386 are known to work. 64-bit Go binaries are known to -fail on 32-bit NetBSD kernels. GOARCH=arm is untested. -

      - -

      -Go 1.10 is the last release that will run on OpenBSD 6.0. -Go 1.11 will require OpenBSD 6.2. +Go now runs on NetBSD again but requires the unreleased NetBSD 8. +Only GOARCH amd64 and 386 have +been fixed. The arm port is still broken.

      @@ -94,13 +86,34 @@ On 32-bit MIPS systems, the new environment variable settings hardware instructions or software emulation for floating-point computations.

      +

      +Go 1.10 is the last release that will run on OpenBSD 6.0. +Go 1.11 will require OpenBSD 6.2. +

      + +

      +Go 1.10 is the last release that will run on OS X 10.8 Mountain Lion or OS X 10.9 Mavericks. +Go 1.11 will require OS X 10.10 Yosemite or later. +

      + +

      +Go 1.10 is the last release that will run on Windows XP or Windows Vista. +Go 1.11 will require Windows 7 or later. +

      +

      Tools

      Default GOROOT & GOTMPDIR

      -TODO: default GOROOT changes in cmd/go -TODO: computed GOROOT change +If the environment variable $GOROOT is unset, +the go tool previously used the default GOROOT +set during toolchain compilation. +Now, before falling back to that default, the go tool attempts to +deduce GOROOT from its own executable path. +This allows binary distributions to be unpacked anywhere in the +file system and then be used without setting GOROOT +explicitly.

      @@ -117,7 +130,7 @@ The go build command now detects out-of-date pack purely based on the content of source files, specified build flags, and metadata stored in the compiled packages. Modification times are no longer consulted or relevant. The old advice to add -a to force a rebuild in cases where -the modification times were misleading for one reason or another +the modification times were misleading for one reason or another (for example, changes in build flags) is no longer necessary: builds now always detect when packages must be rebuilt. (If you observe otherwise, please file a bug.) @@ -146,17 +159,17 @@ back and forth between different branches in a version control system). The old advice to add the -i flag for speed, as in go build -i or go test -i, is no longer necessary: builds run just as fast without -i. -For more details, see go help cache. +For more details, see go help cache.

      -The go install command now installs only the +The go install command now installs only the packages and commands listed directly on the command line. For example, go install cmd/gofmt installs the gofmt program but not any of the packages on which it depends. The new build cache makes future commands still run as quickly as if the dependencies had been installed. -To force the installation of dependencies, use the new +To force the installation of dependencies, use the new go install -i flag. Installing dependency packages should not be necessary in general, and the very concept of installed packages may disappear in a future release. @@ -188,7 +201,7 @@ only to command lines using a subset of the The idiomatic way to bypass test caching is to use -count=1.

      -

      +

      The go test command now automatically runs go vet on the package being tested, to identify significant problems before running the test. @@ -253,7 +266,19 @@ and the test2json documentation.

      Cgo

      -Cgo now implements a C typedef like “typedef X Y;” using a Go type alias, +Options specified by cgo using #cgo CFLAGS and the like +are now checked against a whitelist of permitted options. +This closes a security hole in which a downloaded package uses +compiler options like +-fplugin +to run arbitrary code on the machine where it is being built. +This can cause a build error such as invalid flag in #cgo CFLAGS. +For more background, and how to handle this error, see +https://golang.org/s/invalidflag. +

      + +

      +Cgo now implements a C typedef like “typedef X Y” using a Go type alias, so that Go code may use the types C.X and C.Y interchangeably. It also now supports the use of niladic function-like macros. Also, the documentation has been updated to clarify that @@ -261,9 +286,13 @@ Go structs and Go arrays are not supported in the type signatures of cgo-exporte

      -TODO: CL 70890 "permit passing string values directly between Go and C." -
      -TODO: CL 66332 "special case C ptr types to use uintptr." +Cgo now supports direct access to Go string values from C. +Functions in the C preamble may use the type _GoString_ +to accept a Go string as an argument. +C code may call _GoStringLen and _GoStringPtr +for direct access to the contents of the string. +A value of type _GoString_ +may be passed in a call to an exported Go function that takes an argument of Go type string.

      @@ -275,10 +304,37 @@ The new set of environment variables CC_FOR_goos_goarchgo build commands refer to the CC environment +Later go build commands use the CC environment variable or else the built-in default.

      +

      +Cgo now translates some C types that would normally map to a pointer +type in Go, to a uintptr instead. These types include +the CFTypeRef hierarchy in Darwin's CoreFoundation +framework and the jobject hierarchy in Java's JNI +interface. +

      + +

      +These types must be uintptr on the Go side because they +would otherwise confuse the Go garbage collector; they are sometimes +not really pointers but data structures encoded in a pointer-sized integer. +Pointers to Go memory must not be stored in these uintptr values. +

      + +

      +Because of this change, values of the affected types need to be +zero-initialized with the constant 0 instead of the +constant nil. Go 1.10 provides gofix +modules to help with that rewrite: +

      + +
      +go tool fix -r cftype <pkg>
      +go tool fix -r jni <pkg>
      +
      +

      For more details, see the cgo documentation.

      @@ -296,7 +352,7 @@ $ go doc mail.Address package mail // import "net/mail" type Address struct { - Name string + Name string Address string } Address represents a single mail address. @@ -336,8 +392,9 @@ without the binary that produced the profile.

      -The go tool pprof profile visualizer has been updated to -the latest version from github.com/google/pprof, +The go tool pprof +profile visualizer has been updated to git version 9e20b5b (2017-11-08) +from github.com/google/pprof, which includes an updated web interface.

      @@ -368,7 +425,7 @@ First, certain complex three-index slice expressions previously formatted like x[i+1 : j:k] and now format with more consistent spacing: x[i+1 : j : k]. Second, single-method interface literals written on a single line, -which are sometimes used in type assertions, +which are sometimes used in type assertions, are no longer split onto multiple lines.

      @@ -383,17 +440,10 @@ a repository is not “properly formatted” is inherently fragile and not recom

      If multiple programs must agree about which version of gofmt is used to format a source file, we recommend that they do this by arranging to invoke the same gofmt binary. -For example, in the Go open source repository, we arrange for goimports and -our Git pre-commit hook to agree about source code formatting by having both -invoke the gofmt binary found in the current path. -TODO: Make goimports actually do that. #22695. -As another example, inside Google we arrange that source code presubmit -checks run a gofmt binary maintained at a fixed path in a shared, distributed file system; -that on engineering workstations /usr/bin/gofmt -is a symbolic link to that same path; -and that all editor integrations used for Google development -explicitly invoke /usr/bin/gofmt. -TODO: TMI? +For example, in the Go open source repository, our Git pre-commit hook is written in Go +and could import go/format directly, but instead it invokes the gofmt +binary found in the current path, so that the pre-commit hook need not be recompiled +each time gofmt changes.

      Compiler Toolchain

      @@ -412,10 +462,10 @@ and each package is now presented as its own DWARF compilation unit.

      The various build modes -has been ported to more systems. +have been ported to more systems. Specifically, c-shared now works on linux/ppc64le, windows/386, and windows/amd64; pie now works on darwin/amd64 and also forces the use of external linking on all systems; -and plugin now works on linux/ppc64le. +and plugin now works on linux/ppc64le and darwin/amd64.

      @@ -477,7 +527,7 @@ instructions.

      -For the PowerPC 64-bit port, the assembler now supports the POWER9 instructions +For the PowerPC 64-bit port, the assembler now supports the POWER9 instructions ADDEX, CMPEQB, COPY, @@ -497,7 +547,7 @@ and

      -For the S390X port, the assembler now supports the +For the S390X port, the assembler now supports the TMHH, TMHL, TMLH, @@ -517,7 +567,11 @@ to avoid clearing the condition flags unexpectedly.

      Gccgo

      -TODO: Words about GCC 8 and Go 1.10. +Due to the alignment of Go's semiannual release schedule with GCC's +annual release schedule, +GCC release 7 contains the Go 1.8.3 version of gccgo. +We expect that the next release, GCC 8, will contain the Go 1.10 +version of gccgo.

      Runtime

      @@ -537,7 +591,7 @@ Now, the calls nest: if LockOSThread is called multiple times, in order to unlock the thread. Existing code that was careful not to nest these calls will remain correct. Existing code that incorrectly assumed the calls nested will become correct. -Most uses of these functions in public Go source falls into the second category. +Most uses of these functions in public Go source code falls into the second category.

      @@ -555,12 +609,23 @@ optimization decisions and implementation details.

      -There is no longer a limit on the GOMAXPROCS setting. -(In Go 1.9 the limit was 1024.) +The garbage collector has been modified to reduce its impact on allocation latency. +It now uses a smaller fraction of the overall CPU when running, but it may run more of the time. +The total CPU consumed by the garbage collector has not changed significantly.

      -TODO: Anything about CL 59970: "runtime: separate soft and hard heap limits"? +The GOROOT function +now defaults (when the $GOROOT environment variable is not set) +to the GOROOT or GOROOT_FINAL in effect +at the time the calling program was compiled. +Previously it used the GOROOT or GOROOT_FINAL in effect +at the time the toolchain that compiled the calling program was compiled. +

      + +

      +There is no longer a limit on the GOMAXPROCS setting. +(In Go 1.9 the limit was 1024.)

      Performance

      @@ -689,9 +754,9 @@ The Split, and SplitAfter -each already returned slices pointing into the same underlying array as its input. -Go 1.10 changes each of the returned subslices to have capacity equal to its length, -so that appending to a subslice will not overwrite adjacent data in the original input. +functions have always returned subslices of their inputs. +Go 1.10 changes each returned subslice to have capacity equal to its length, +so that appending to one cannot overwrite adjacent data in the original input.

      @@ -717,13 +782,13 @@ them unless explicitly advertised.
      crypto/x509

      -Leaf certificate validation now enforces the name constraints for all +Certificate.Verify +now enforces the name constraints for all names contained in the certificate, not just the one name that a client has asked about. Extended key usage restrictions are similarly now checked all at once. As a result, after a certificate has been validated, now it can be trusted in its entirety. It is no longer necessary to revalidate the certificate for each additional name or key usage. -TODO: Link to docs that may not exist yet.

      @@ -731,7 +796,8 @@ Parsed certificates also now report URI names and IP, email, and URI constraints Certificate fields URIs, PermittedIPRanges, ExcludedIPRanges, PermittedEmailAddresses, ExcludedEmailAddresses, -PermittedURIDomains, and ExcludedURIDomains. +PermittedURIDomains, and ExcludedURIDomains. Certificates with +invalid values for those fields are now rejected.

      @@ -760,6 +826,13 @@ formats the X.509 distinguished name in the standard RFC 2253 format.

      database/sql/driver

      +Drivers that currently hold on to the destination buffer provided by +driver.Rows.Next should ensure they no longer +write to a buffer assigned to the destination array outside of that call. +Drivers must be careful that underlying buffers are not modified when closing +driver.Rows. +

      +

      Drivers that want to construct a sql.DB for their clients can now implement the Connector interface and call the new sql.OpenDB function, @@ -819,8 +892,8 @@ types and associated constants.

      Go 1.10 also adds support for the LC_RPATH load command, -represented by the types -RpathCmd and +represented by the types +RpathCmd and Rpath, and new named constants for the various flag bits found in headers. @@ -860,7 +933,7 @@ such as NUL, carriage return, newline, invalid runes, and the Unicode replacemen or setting Comma and Comment equal to each other.

      -In the case of a syntax error in a CSV record that spans multiple input lines, Reader +In the case of a syntax error in a CSV record that spans multiple input lines, Reader now reports the line on which the record started in the ParseError's new StartLine field.

      @@ -870,17 +943,17 @@ now reports the line on which the record started in the NewEncoder -and +and NewDecoder provide streaming conversions to and from hexadecimal, -analogous to equivalent functions already in +analogous to equivalent functions already in encoding/base32 and encoding/base64.

      -When the functions +When the functions Decode and DecodeString @@ -928,7 +1001,7 @@ block that is impossible to encode as PEM data.

      The new function NewTokenDecoder -is like +is like NewDecoder but creates a decoder reading from a TokenReader instead of an XML-formatted byte stream. @@ -941,7 +1014,7 @@ This is meant to enable the construction of XML stream transformers in client li

      The default Usage function now prints -its first line of output to +its first line of output to CommandLine.Output() instead of assuming os.Stderr, so that the usage message is properly redirected for @@ -1008,12 +1081,10 @@ now implement those interfaces.

      html/template

      -The new actions {{"{{break}}"}} and {{"{{continue}}"}} -break out of the innermost {{"{{range"}} ...}} loop, -like the corresponding Go statements. -

      -

      -TODO: something about the AddParseTree problem (#21844). +The new Srcset content +type allows for proper handling of values within the +srcset +attribute of img tags.

      @@ -1026,9 +1097,9 @@ in its SetString and MaxBase has been updated.

      -Int adds a new +Int adds a new CmpAbs method -that is like Cmp but +that is like Cmp but compares only the absolute values (not the signs) of its arguments.

      @@ -1042,11 +1113,11 @@ compute square roots.

      Branch cuts and other boundary cases in -Asin, -Asinh, -Atan, +Asin, +Asinh, +Atan, and -Sqrt +Sqrt have been corrected to match the definitions used in the C99 standard.

      @@ -1113,7 +1184,7 @@ goroutines shortly after Close returned.)

      TCPListener and UnixListener -now implement +now implement syscall.Conn, to allow setting options on the underlying file descriptor using syscall.RawConn.Control. @@ -1154,14 +1225,11 @@ The content-serving handlers also now omit the Content-Type header if passed an invalid (non-3-digit) status code.

      -Redirect now sets the Content-Type header before writing its HTTP response. + +The Server will no longer add an implicit Content-Type when a Handler does not write any output.

      - - -
      net/http/httputil
      -

      -TODO: ReverseProxy and back end errors and ModifyResponse. +Redirect now sets the Content-Type header before writing its HTTP response.

      @@ -1200,7 +1268,7 @@ were not indented.

      ResolveReference -now preseves multiple leading slashes in the target URL. +now preserves multiple leading slashes in the target URL. Previously it rewrote multiple leading slashes to a single slash, which resulted in the http.Client following certain redirects incorrectly. @@ -1249,22 +1317,26 @@ and that allow setting I/O deadlines when the underlying file descriptor supports non-blocking I/O operations. The definition of these methods matches those in net.Conn. +If an I/O method fails due to missing a deadline, it will return a +timeout error; the +new IsTimeout function +reports whether an error represents a timeout.

      Also matching net.Conn, -File's +File's Close method now guarantee that when Close returns, the underlying file descriptor has been closed. -(In earlier releases, like for net.Conn's, +(In earlier releases, if the Close stopped pending I/O in other goroutines, the closing of the file descriptor could happen in one of those goroutines shortly after Close returned.)

      -On BSD, macOS, and Solaris systems, +On BSD, macOS, and Solaris systems, Chtimes now supports setting file times with nanosecond precision (assuming the underlying file system can represent them). @@ -1286,7 +1358,7 @@ in the corresponding StructField, with the result that for those fields, and Value.CanSet incorrectly returned true and -and Value.Set +Value.Set incorrectly succeeded. The underlying metadata has been corrected; for those fields, @@ -1297,7 +1369,6 @@ that could previously unmarshal into such fields but no longer can. For example, see the encoding/json notes.

      -

      runtime/pprof
      @@ -1312,7 +1383,7 @@ the binary that generated them.
      strconv

      -ParseUint now returns +ParseUint now returns the maximum magnitude integer of the appropriate size with any ErrRange error, as it was already documented to do. Previously it returned 0 with ErrRange errors. @@ -1351,15 +1422,6 @@ is now implemented.

      -
      text/template
      -
      -

      -The new actions {{"{{break}}"}} and {{"{{continue}}"}} -break out of the innermost {{"{{range"}} ...}} loop, -like the corresponding Go statements. -

      -
      -
      time

      @@ -1378,7 +1440,7 @@ allows conversion of IANA time zone file data to a

      The unicode package and associated -support throughout the system has been upgraded from version 9.0 to +support throughout the system has been upgraded from Unicode 9.0 to Unicode 10.0, which adds 8,518 new characters, including four new scripts, one new property, a Bitcoin currency symbol, and 56 new emoji. diff --git a/doc/go1.2.html b/doc/go1.2.html index b9d36f29c3d..5370bbbbd6e 100644 --- a/doc/go1.2.html +++ b/doc/go1.2.html @@ -266,7 +266,7 @@ is now an error.

      On the ARM, the toolchain supports "external linking", which is a step towards being able to build shared libraries with the gc -tool chain and to provide dynamic linking support for environments +toolchain and to provide dynamic linking support for environments in which that is necessary.

      diff --git a/doc/go1.3.html b/doc/go1.3.html index d51052b2e5e..18c638a1b5e 100644 --- a/doc/go1.3.html +++ b/doc/go1.3.html @@ -11,7 +11,7 @@ The latest Go release, version 1.3, arrives six months after 1.2, and contains no language changes. It focuses primarily on implementation work, providing precise garbage collection, -a major refactoring of the compiler tool chain that results in +a major refactoring of the compiler toolchain that results in faster builds, especially for large projects, significant performance improvements across the board, and support for DragonFly BSD, Solaris, Plan 9 and Google's Native Client architecture (NaCl). @@ -285,7 +285,7 @@ building and linking with a shared library.

      Command-line flag parsing

      -In the gc tool chain, the assemblers now use the +In the gc toolchain, the assemblers now use the same command-line flag parsing rules as the Go flag package, a departure from the traditional Unix flag parsing. This may affect scripts that invoke the tool directly. diff --git a/doc/go1.html b/doc/go1.html index 1665d74e955..34e305b93cd 100644 --- a/doc/go1.html +++ b/doc/go1.html @@ -775,7 +775,7 @@ to turn a string into an error. It replaces the old os.NewError.

      {{code "/doc/progs/go1.go" `/ErrSyntax/`}} - +

      Updating: Running go fix will update almost all code affected by the change. @@ -1827,7 +1827,7 @@ for full details. Uitob(x, b) FormatUint(uint64(x), b) Uitob64(x, b) FormatUint(x, b) - +

      Updating: Running go fix will update almost all code affected by the change. @@ -1841,7 +1841,7 @@ a cast that must be added by hand; the go fix tool wil

      The template packages

      -The template and exp/template/html packages have moved to +The template and exp/template/html packages have moved to text/template and html/template. More significant, the interface to these packages has been simplified. @@ -2035,4 +2035,4 @@ They are available for many combinations of architecture and operating system Installation details are described on the Getting Started page, while the distributions themselves are listed on the -downloads page. +downloads page. diff --git a/doc/go1compat.html b/doc/go1compat.html index 607d3546876..a5624ef5f67 100644 --- a/doc/go1compat.html +++ b/doc/go1compat.html @@ -190,8 +190,8 @@ For details and background, see

      Tools

      -Finally, the Go tool chain (compilers, linkers, build tools, and so -on) are under active development and may change behavior. This +Finally, the Go toolchain (compilers, linkers, build tools, and so +on) is under active development and may change behavior. This means, for instance, that scripts that depend on the location and properties of the tools may be broken by a point release.

      diff --git a/doc/go_faq.html b/doc/go_faq.html index a3cb8731fa4..99a0e4a5507 100644 --- a/doc/go_faq.html +++ b/doc/go_faq.html @@ -479,6 +479,15 @@ as when hosting an untrusted program, the implementation could interlock map access.

      +

      +Map access is unsafe only when updates are occurring. +As long as all goroutines are only reading—looking up elements in the map, +including iterating through it using a +for range loop—and not changing the map +by assigning to elements or doing deletions, +it is safe for them to access the map concurrently without synchronization. +

      +

      Will you accept my language change?

      @@ -1088,24 +1097,27 @@ The go get command therefore uses HTTPS for safety.

      -If you use git and prefer to push changes through SSH using your existing key -it's easy to work around this. For GitHub, try one of these solutions: +Git can be configured to authenticate over HTTPS or to use SSH in place of HTTPS. +To authenticate over HTTPS, you can add a line +to the $HOME/.netrc file that git consults:

      -
        -
      • Manually clone the repository in the expected package directory:
        -$ cd src/github.com/username
        -$ git clone git@github.com:username/package.git
        +machine github.com login USERNAME password APIKEY
         
        -
      • -
      • Force git push to use the SSH protocol by appending -these two lines to ~/.gitconfig: +

        +For GitHub accounts, the password can be a +personal access token. +

        + +

        +Git can also be configured to use SSH in place of HTTPS for URLs matching a given prefix. +For example, to use SSH for all GitHub access, +add these lines to your ~/.gitconfig: +

        -[url "git@github.com:"]
        -	pushInsteadOf = https://github.com/
        +[url "ssh://git@github.com/"]
        +	insteadOf = https://github.com/
         
        -
      • -

      How should I manage package versions using "go get"?

      @@ -1842,19 +1854,20 @@ supported by recent modifications to the gold linker. Why is my trivial program such a large binary?

      -The linker in the gc tool chain -creates statically-linked binaries by default. All Go binaries therefore include the Go +The linker in the gc toolchain +creates statically-linked binaries by default. +All Go binaries therefore include the Go run-time, along with the run-time type information necessary to support dynamic type checks, reflection, and even panic-time stack traces.

      -A simple C "hello, world" program compiled and linked statically using gcc -on Linux is around 750 kB, -including an implementation of printf. -An equivalent Go program using fmt.Printf -is around 1.5 MB, but -that includes more powerful run-time support and type information. +A simple C "hello, world" program compiled and linked statically using +gcc on Linux is around 750 kB, including an implementation of +printf. +An equivalent Go program using +fmt.Printf weighs a couple of megabytes, but that includes +more powerful run-time support and type and debugging information.

      @@ -1922,6 +1935,26 @@ eliminating the unused imports issue in practice. This program is easily connected to most editors to run automatically when a Go source file is written.

      +

      +Why does my virus-scanning software think my Go distribution or compiled binary is infected?

      + +

      +This is a common occurrence, especially on Windows machines, and is almost always a false positive. +Commercial virus scanning programs are often confused by the structure of Go binaries, which +they don't see as often as those compiled from other languages. +

      + +

      +If you've just installed the Go distribution and the system reports it is infected, that's certainly a mistake. +To be really thorough, you can verify the download by comparing the checksum with those on the +downloads page. +

      + +

      +In any case, if you believe the report is in error, please report a bug to the supplier of your virus scanner. +Maybe in time virus scanners can learn to understand Go programs. +

      +

      Performance

      diff --git a/doc/go_spec.html b/doc/go_spec.html index ebf1cefffea..f1300c105a4 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -694,9 +694,8 @@ TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType

      -Named instances of the boolean, numeric, and string types are -predeclared. -Other named types are introduced with type declarations. +The language predeclares certain type names. +Others are introduced with type declarations. Composite types—array, struct, pointer, function, interface, slice, map, and channel types—may be constructed using type literals. @@ -1025,8 +1024,8 @@ of a struct except that they cannot be used as field names in

      -Given a struct type S and a type named T, -promoted methods are included in the method set of the struct as follows: +Given a struct type S and a defined type +T, promoted methods are included in the method set of the struct as follows:

      • @@ -1453,9 +1452,9 @@ components have identical types. In detail: Non-exported method names from different packages are always different. The order of the methods is irrelevant.
      • -
      • Two map types are identical if they have identical key and value types.
      • +
      • Two map types are identical if they have identical key and element types.
      • -
      • Two channel types are identical if they have identical value types and +
      • Two channel types are identical if they have identical element types and the same direction.
      @@ -1495,7 +1494,7 @@ A2 and struct{ a, b int } A3 and int A4, func(int, float64) *[]string, and A5 -B0, B0, and C0 +B0 and C0 []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 @@ -2149,9 +2148,8 @@ to a function.

      -FunctionDecl = "func" FunctionName ( Function | Signature ) .
      +FunctionDecl = "func" FunctionName Signature [ FunctionBody ] .
       FunctionName = identifier .
      -Function     = Signature FunctionBody .
       FunctionBody = Block .
       
      @@ -2197,7 +2195,7 @@ and associates the method with the receiver's base type.

      -MethodDecl = "func" Receiver MethodName ( Function | Signature ) .
      +MethodDecl = "func" Receiver MethodName Signature [ FunctionBody ] .
       Receiver   = Parameters .
       
      @@ -2519,7 +2517,7 @@ A function literal represents an anonymous func

      -FunctionLit = "func" Function .
      +FunctionLit = "func" Signature FunctionBody .
       
      @@ -2643,8 +2641,8 @@ expression is illegal.
       
       
       
    • -As an exception, if the type of x is a named pointer type -and (*x).f is a valid selector expression denoting a field +As an exception, if the type of x is a defined +pointer type and (*x).f is a valid selector expression denoting a field (but not a method), x.f is shorthand for (*x).f.
    • @@ -3033,11 +3031,11 @@ For a of map type M: assignable to the key type of M
    • if the map contains an entry with key x, - a[x] is the map value with key x - and the type of a[x] is the value type of M
    • + a[x] is the map element with key x + and the type of a[x] is the element type of M
    • if the map is nil or does not contain such an entry, a[x] is the zero value - for the value type of M
    • + for the element type of M

    @@ -3053,7 +3051,6 @@ used in an assignment or initialization of the specia v, ok = a[x] v, ok := a[x] var v, ok = a[x] -var v, ok T = a[x]

    @@ -3558,9 +3555,10 @@ with x / y truncated towards zero

    -As an exception to this rule, if the dividend x is the most -negative value for the int type of x, the quotient -q = x / -1 is equal to x (and r = 0). +The one exception to this rule is that if the dividend x is +the most negative value for the int type of x, the quotient +q = x / -1 is equal to x (and r = 0) +due to two's-complement integer overflow:

    @@ -3619,15 +3617,15 @@ For unsigned integer values, the operations +,
     computed modulo 2n, where n is the bit width of
     the unsigned integer's type.
     Loosely speaking, these unsigned integer operations
    -discard high bits upon overflow, and programs may rely on ``wrap around''.
    +discard high bits upon overflow, and programs may rely on "wrap around".
     

    For signed integers, the operations +, --, *, and << may legally +-, *, /, and << may legally overflow and the resulting value exists and is deterministically defined by the signed integer representation, the operation, and its operands. -No exception is raised as a result of overflow. A -compiler may not optimize code under the assumption that overflow does +No exception is raised as a result of overflow. +A compiler may not optimize code under the assumption that overflow does not occur. For instance, it may not assume that x < x + 1 is always true.

    @@ -4162,11 +4160,6 @@ operands and are evaluated at compile time. Untyped boolean, numeric, and string constants may be used as operands wherever it is legal to use an operand of boolean, numeric, or string type, respectively. -Except for shift operations, if the operands of a binary operation are -different kinds of untyped constants, the operation and, for non-boolean operations, the result use -the kind that appears later in this list: integer, rune, floating-point, complex. -For example, an untyped integer constant divided by an -untyped complex constant yields an untyped complex constant.

    @@ -4176,9 +4169,17 @@ an untyped boolean constant. If the left operand of a constant result is an integer constant; otherwise it is a constant of the same type as the left operand, which must be of integer type. -Applying all other operators to untyped constants results in an untyped -constant of the same kind (that is, a boolean, integer, floating-point, -complex, or string constant). +

    + +

    +Any other operation on untyped constants results in an untyped constant of the +same kind; that is, a boolean, integer, floating-point, complex, or string +constant. +If the untyped operands of a binary operation (other than a shift) are of +different kinds, the result is of the operand's kind that appears later in this +list: integer, rune, floating-point, complex. +For example, an untyped integer constant divided by an +untyped complex constant yields an untyped complex constant.

    @@ -4356,7 +4357,9 @@ SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | S
     

    Terminating statements

    -A terminating statement is one of the following: +A terminating statement prevents execution of all statements that lexically +appear after it in the same block. The following statements +are terminating:

      @@ -5120,7 +5123,7 @@ for i, s := range a { } var key string -var val interface {} // value type of m is assignable to val +var val interface {} // element type of m is assignable to val m := map[string]int{"mon":0, "tue":1, "wed":2, "thu":3, "fri":4, "sat":5, "sun":6} for key, val = range m { h(key, val) diff --git a/doc/install-source.html b/doc/install-source.html index 17b6ed3ea12..1928b0ba9b4 100644 --- a/doc/install-source.html +++ b/doc/install-source.html @@ -24,7 +24,7 @@ packages, though, read on.

      -There are two official Go compiler tool chains. +There are two official Go compiler toolchains. This document focuses on the gc Go compiler and tools. For information on how to work on gccgo, a more traditional @@ -119,7 +119,7 @@ Go does not support CentOS 6 on these systems.

      Install Go compiler binaries

      -The Go tool chain is written in Go. To build it, you need a Go compiler installed. +The Go toolchain is written in Go. To build it, you need a Go compiler installed. The scripts that do the initial build of the tools look for an existing Go tool chain in $GOROOT_BOOTSTRAP. If unset, the default value of GOROOT_BOOTSTRAP @@ -127,26 +127,26 @@ is $HOME/go1.4.

      -There are many options for the bootstrap tool chain. +There are many options for the bootstrap toolchain. After obtaining one, set GOROOT_BOOTSTRAP to the directory containing the unpacked tree. For example, $GOROOT_BOOTSTRAP/bin/go should be -the go command binary for the bootstrap tool chain. +the go command binary for the bootstrap toolchain.

      -To use a binary release as a bootstrap tool chain, see +To use a binary release as a bootstrap toolchain, see the downloads page or use any other packaged Go distribution.

      -To build a bootstrap tool chain from source, use +To build a bootstrap toolchain from source, use either the git branch release-branch.go1.4 or go1.4-bootstrap-20171003.tar.gz, 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.) +(Go 1.4 was the last distribution in which the toolchain was written in C.) After unpacking the Go 1.4 source, cd to the src subdirectory, set CGO_ENABLED=0 in the environment, and run make.bash (or, @@ -154,7 +154,7 @@ on Windows, make.bat).

      -To cross-compile a bootstrap tool chain from source, which is +To cross-compile a bootstrap toolchain from source, which is necessary on systems Go 1.4 did not target (for example, linux/ppc64le), install Go on a different system and run bootstrap.bash. @@ -307,7 +307,7 @@ package main import "fmt" func main() { - fmt.Printf("hello, world\n") + fmt.Printf("hello, world\n") }

    @@ -446,6 +446,7 @@ defaults to the parent of the directory where all.bash was run. There is no need to set this unless you want to switch between multiple local copies of the repository.

    +
  • $GOROOT_FINAL

    @@ -456,12 +457,14 @@ If you want to build the Go tree in one location but move it elsewhere after the build, set $GOROOT_FINAL to the eventual location.

    +
  • $GOOS and $GOARCH

    The name of the target operating system and compilation architecture. These default to the values of $GOHOSTOS and $GOHOSTARCH respectively (described below). +

  • Choices for $GOOS are @@ -582,6 +585,7 @@ The name of the host operating system and compilation architecture. These default to the local system's operating system and architecture.

    +

    Valid choices are the same as for $GOOS and @@ -600,6 +604,7 @@ directory to your $PATH, so you can use the tools. If $GOBIN is set, the go command installs all commands there.

    +
  • $GO386 (for 386 only, default is auto-detected if built on either 386 or amd64, 387 otherwise) @@ -609,9 +614,10 @@ This controls the code generated by gc to use either the 387 floating-point unit floating point computations.

      -
    • GO386=387: use x87 for floating point operations; should support all x86 chips (Pentium MMX or later). -
    • GO386=sse2: use SSE2 for floating point operations; has better performance than 387, but only available on Pentium 4/Opteron/Athlon 64 or later. +
    • GO386=387: use x87 for floating point operations; should support all x86 chips (Pentium MMX or later).
    • +
    • GO386=sse2: use SSE2 for floating point operations; has better performance than 387, but only available on Pentium 4/Opteron/Athlon 64 or later.
    +
  • $GOARM (for arm only; default is auto-detected if building on the target processor, 6 if not) @@ -620,9 +626,9 @@ This sets the ARM floating point co-processor architecture version the run-time should target. If you are compiling on the target system, its value will be auto-detected.

      -
    • GOARM=5: use software floating point; when CPU doesn't have VFP co-processor -
    • GOARM=6: use VFPv1 only; default if cross compiling; usually ARM11 or better cores (VFPv2 or better is also supported) -
    • GOARM=7: use VFPv3; usually Cortex-A cores +
    • GOARM=5: use software floating point; when CPU doesn't have VFP co-processor
    • +
    • GOARM=6: use VFPv1 only; default if cross compiling; usually ARM11 or better cores (VFPv2 or better is also supported)
    • +
    • GOARM=7: use VFPv3; usually Cortex-A cores

    If in doubt, leave this variable unset, and adjust it if required @@ -631,6 +637,17 @@ The GoARM page on the Go community wiki contains further details regarding Go's ARM support.

    +
  • + +
  • $GOMIPS (for mips and mipsle only) +

    +This sets whether to use floating point instructions. +

    +
      +
    • GOMIPS=hardfloat: use floating point instructions (the default)
    • +
    • GOMIPS=softfloat: use soft floating point
    • +
    +
  • diff --git a/doc/install.html b/doc/install.html index abf7fa6daed..ee1516ac47b 100644 --- a/doc/install.html +++ b/doc/install.html @@ -8,14 +8,14 @@

    Download the Go distribution

    - + Download Go Click here to visit the downloads page

    -Official binary +Official binary distributions are available for the FreeBSD (release 10-STABLE and above), Linux, Mac OS X (10.8 and above), and Windows operating systems and the 32-bit (386) and 64-bit (amd64) x86 processor @@ -33,7 +33,7 @@ system and architecture, try

    System requirements

    -Go binary distributions are available for these supported operating systems and architectures. +Go binary distributions are available for these supported operating systems and architectures. Please ensure your system meets these requirements before proceeding. If your OS or architecture is not on the list, you may be able to install from source or @@ -77,7 +77,7 @@ first remove the existing version.

    Linux, Mac OS X, and FreeBSD tarballs

    -Download the archive +Download the archive and extract it into /usr/local, creating a Go tree in /usr/local/go. For example:

    @@ -106,6 +106,14 @@ variable. You can do this by adding this line to your /etc/profile export PATH=$PATH:/usr/local/go/bin +

    +Note: changes made to a profile file may not apply until the +next time you log into your computer. +To apply the changes immediately, just run the shell commands directly +or execute them from the profile using a command such as +source $HOME/.profile. +

    +

    Installing to a custom location

    @@ -138,7 +146,7 @@ location.

    Mac OS X package installer

    -Download the package file, +Download the package file, open it, and follow the prompts to install the Go tools. The package installs the Go distribution to /usr/local/go.

    @@ -167,7 +175,7 @@ MSI installer that configures your installation automatically.

    MSI installer

    -Open the MSI file +Open the MSI file and follow the prompts to install the Go tools. By default, the installer puts the Go distribution in c:\Go.

    @@ -185,7 +193,7 @@ command prompts for the change to take effect.

    Zip archive

    -Download the zip file and extract it into the directory of your choice (we suggest c:\Go). +Download the zip file and extract it into the directory of your choice (we suggest c:\Go).

    @@ -236,7 +244,7 @@ package main import "fmt" func main() { - fmt.Printf("hello, world\n") + fmt.Printf("hello, world\n") } @@ -278,7 +286,7 @@ If you see the "hello, world" message then your Go installation is working.

    You can run go install to install the binary into your workspace's bin directory -or go clean to remove it. +or go clean -i to remove it.

    diff --git a/doc/progs/error2.go b/doc/progs/error2.go index 2b0e0c3563a..086b6710d36 100644 --- a/doc/progs/error2.go +++ b/doc/progs/error2.go @@ -20,11 +20,11 @@ func viewRecord(w http.ResponseWriter, r *http.Request) { key := datastore.NewKey(c, "Record", r.FormValue("id"), 0, nil) record := new(Record) if err := datastore.Get(c, key, record); err != nil { - http.Error(w, err.Error(), 500) + http.Error(w, err.Error(), http.StatusInternalServerError) return } if err := viewTemplate.Execute(w, record); err != nil { - http.Error(w, err.Error(), 500) + http.Error(w, err.Error(), http.StatusInternalServerError) } } diff --git a/doc/progs/error3.go b/doc/progs/error3.go index e4e57e077b5..d9e56b5d64e 100644 --- a/doc/progs/error3.go +++ b/doc/progs/error3.go @@ -33,7 +33,7 @@ type appHandler func(http.ResponseWriter, *http.Request) error func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if err := fn(w, r); err != nil { - http.Error(w, err.Error(), 500) + http.Error(w, err.Error(), http.StatusInternalServerError) } } diff --git a/doc/root.html b/doc/root.html index 9bdf9274804..545b28d2d5c 100644 --- a/doc/root.html +++ b/doc/root.html @@ -58,7 +58,7 @@ simple, reliable, and efficient software.

    - + Download Go Binary distributions available for
    @@ -74,7 +74,7 @@ Linux, Mac OS X, Windows, and more.
    Featured video
    - +
    @@ -153,6 +153,10 @@ Linux, Mac OS X, Windows, and more. ]; var v = videos[Math.floor(Math.random()*videos.length)]; $('#video iframe').attr('height', v.h).attr('src', v.s); + // Compute the aspect ratio (as a percentage) of the video + // using the fixed width 415 and the height of the current video, v.h. + var ar = 100*v.h/415; + $('.js-frontpage-video').attr('style', '--aspect-ratio-padding: ' + ar + '%;'); }); {{end}} diff --git a/lib/time/README b/lib/time/README index ffce9b0e085..aab4daa7e2d 100644 --- a/lib/time/README +++ b/lib/time/README @@ -3,7 +3,7 @@ the code and data maintained as part of the IANA Time Zone Database. The IANA asserts that the database is in the public domain. For more information, see -http://www.iana.org/time-zones +https://www.iana.org/time-zones ftp://ftp.iana.org/tz/code/tz-link.htm http://tools.ietf.org/html/rfc6557 diff --git a/lib/time/update.bash b/lib/time/update.bash index 16552fb6f91..26ad79d52de 100755 --- a/lib/time/update.bash +++ b/lib/time/update.bash @@ -5,7 +5,7 @@ # This script rebuilds the time zone files using files # downloaded from the ICANN/IANA distribution. -# Consult http://www.iana.org/time-zones for the latest versions. +# Consult https://www.iana.org/time-zones for the latest versions. # Versions to use. CODE=2017c @@ -16,8 +16,8 @@ rm -rf work mkdir work cd work mkdir zoneinfo -curl -O http://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz -curl -O http://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz +curl -L -O https://www.iana.org/time-zones/repository/releases/tzcode$CODE.tar.gz +curl -L -O https://www.iana.org/time-zones/repository/releases/tzdata$DATA.tar.gz tar xzf tzcode$CODE.tar.gz tar xzf tzdata$DATA.tar.gz @@ -42,10 +42,9 @@ 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 fi echo New time zone files in zoneinfo.zip. - diff --git a/misc/android/README b/misc/android/README index 7b17d879e86..a0dd8500ee0 100644 --- a/misc/android/README +++ b/misc/android/README @@ -8,4 +8,17 @@ mobile subrepository: To run the standard library tests, see androidtest.bash. Run it as - CC_FOR_TARGET=.../ndk-gcc GOARCH=arm GOARM=7 ./androidtest.bash + CC_FOR_TARGET=$STANDALONE_NDK_PATH/bin/clang GOARCH=arm64 ./androidtest.bash + +To create a standalone android NDK tool chain, follow the instructions on + + https://developer.android.com/ndk/guides/standalone_toolchain + +To run tests on the Android device, add the bin directory to PATH so the +go tool can find the go_android_$GOARCH_exec wrapper generated by +androidtest.bash. Then, use the same GOARCH as when androidtest.bash ran +and set GOOS to android. For example, to run the go1 benchmarks + + export PATH=$GOROOT/bin:$PATH + cd $GOROOT/test/bench/go1/ + GOOS=android GOARCH=arm64 go test -bench=. -count=N -timeout=T \ No newline at end of file diff --git a/misc/android/go_android_exec.go b/misc/android/go_android_exec.go index 49b7ae902c3..5671479d879 100644 --- a/misc/android/go_android_exec.go +++ b/misc/android/go_android_exec.go @@ -21,6 +21,9 @@ import ( ) func run(args ...string) string { + if flags := os.Getenv("GOANDROID_ADB_FLAGS"); flags != "" { + args = append(strings.Split(flags, " "), args...) + } buf := new(bytes.Buffer) cmd := exec.Command("adb", args...) cmd.Stdout = io.MultiWriter(os.Stdout, buf) diff --git a/misc/cgo/errors/ptr_test.go b/misc/cgo/errors/ptr_test.go index d295a5849db..fe8dfff1d89 100644 --- a/misc/cgo/errors/ptr_test.go +++ b/misc/cgo/errors/ptr_test.go @@ -349,6 +349,14 @@ var ptrTests = []ptrTest{ body: `var wg sync.WaitGroup; wg.Add(100); for i := 0; i < 100; i++ { go func(i int) { for j := 0; j < 100; j++ { C.f(); runtime.GOMAXPROCS(i) }; wg.Done() }(i) }; wg.Wait()`, fail: false, }, + { + // Test poller deadline with cgocheck=2. Issue #23435. + name: "deadline", + c: `#define US 10`, + imports: []string{"os", "time"}, + body: `r, _, _ := os.Pipe(); r.SetDeadline(time.Now().Add(C.US * time.Microsecond))`, + fail: false, + }, } func TestPointerChecks(t *testing.T) { diff --git a/misc/cgo/errors/src/err1.go b/misc/cgo/errors/src/err1.go index 61bbcd29577..2c232cf58a7 100644 --- a/misc/cgo/errors/src/err1.go +++ b/misc/cgo/errors/src/err1.go @@ -5,7 +5,7 @@ package main /* -#cgo LDFLAGS: -c +#cgo LDFLAGS: -L/nonexist void test() { xxx; // ERROR HERE diff --git a/misc/cgo/test/basic.go b/misc/cgo/test/basic.go index 3ceb4ce8470..2655a66e381 100644 --- a/misc/cgo/test/basic.go +++ b/misc/cgo/test/basic.go @@ -31,6 +31,8 @@ struct S { int x; }; +const char *cstr = "abcefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + extern enum E myConstFunc(struct S* const ctx, int const id, struct S **const filter); enum E myConstFunc(struct S *const ctx, int const id, struct S **const filter) { return 0; } @@ -149,6 +151,18 @@ func benchCgoCall(b *testing.B) { } } +var sinkString string + +func benchGoString(b *testing.B) { + for i := 0; i < b.N; i++ { + sinkString = C.GoString(C.cstr) + } + const want = "abcefghijklmnopqrstuvwxyzABCEFGHIJKLMNOPQRSTUVWXYZ1234567890" + if sinkString != want { + b.Fatalf("%q != %q", sinkString, want) + } +} + // Issue 2470. func testUnsignedInt(t *testing.T) { a := (int64)(C.UINT32VAL) diff --git a/misc/cgo/test/buildid_linux.go b/misc/cgo/test/buildid_linux.go index 47dd87128ff..84d3edb664e 100644 --- a/misc/cgo/test/buildid_linux.go +++ b/misc/cgo/test/buildid_linux.go @@ -27,6 +27,7 @@ func testBuildID(t *testing.T) { defer f.Close() c := 0 +sections: for i, s := range f.Sections { if s.Type != elf.SHT_NOTE { continue @@ -47,7 +48,7 @@ func testBuildID(t *testing.T) { if len(d) < 12 { t.Logf("note section %d too short (%d < 12)", i, len(d)) - continue + continue sections } namesz := f.ByteOrder.Uint32(d) @@ -59,7 +60,7 @@ func testBuildID(t *testing.T) { if int(12+an+ad) > len(d) { t.Logf("note section %d too short for header (%d < 12 + align(%d,4) + align(%d,4))", i, len(d), namesz, descsz) - continue + continue sections } // 3 == NT_GNU_BUILD_ID diff --git a/misc/cgo/test/cgo_test.go b/misc/cgo/test/cgo_test.go index 67abfff2c03..4462df00598 100644 --- a/misc/cgo/test/cgo_test.go +++ b/misc/cgo/test/cgo_test.go @@ -86,5 +86,9 @@ func Test21809(t *testing.T) { test21809(t) } func Test6907(t *testing.T) { test6907(t) } func Test6907Go(t *testing.T) { test6907Go(t) } func Test21897(t *testing.T) { test21897(t) } +func Test22906(t *testing.T) { test22906(t) } +func Test24206(t *testing.T) { test24206(t) } +func Test25143(t *testing.T) { test25143(t) } -func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) } +func BenchmarkCgoCall(b *testing.B) { benchCgoCall(b) } +func BenchmarkGoString(b *testing.B) { benchGoString(b) } diff --git a/misc/cgo/test/issue19832.go b/misc/cgo/test/issue19832.go deleted file mode 100644 index 44587770af4..00000000000 --- a/misc/cgo/test/issue19832.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2015 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 19832. Functions taking a pointer typedef were being expanded and triggering a compiler error. - -package cgotest - -// typedef struct { int i; } *PS; -// void T19832(PS p) {} -import "C" -import "testing" - -func test19832(t *testing.T) { - C.T19832(nil) -} diff --git a/misc/cgo/test/issue24206.go b/misc/cgo/test/issue24206.go new file mode 100644 index 00000000000..5fec68e8803 --- /dev/null +++ b/misc/cgo/test/issue24206.go @@ -0,0 +1,54 @@ +// +build amd64,linux + +// Copyright 2018 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 + +// Test that C.GoString uses IndexByte in safe manner. + +/* +#include + +// Returns string with null byte at the last valid address +char* dangerousString1() { + int pageSize = 4096; + char *data = mmap(0, 2 * pageSize, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, 0, 0); + mprotect(data + pageSize,pageSize,PROT_NONE); + int start = pageSize - 123 - 1; // last 123 bytes of first page + 1 null byte + int i = start; + for (; i < pageSize; i++) { + data[i] = 'x'; + } + data[pageSize -1 ] = 0; + return data+start; +} + +char* dangerousString2() { + int pageSize = 4096; + char *data = mmap(0, 3 * pageSize, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, 0, 0); + mprotect(data + 2 * pageSize,pageSize,PROT_NONE); + int start = pageSize - 123 - 1; // last 123 bytes of first page + 1 null byte + int i = start; + for (; i < 2 * pageSize; i++) { + data[i] = 'x'; + } + data[2*pageSize -1 ] = 0; + return data+start; +} +*/ +import "C" + +import ( + "testing" +) + +func test24206(t *testing.T) { + if l := len(C.GoString(C.dangerousString1())); l != 123 { + t.Errorf("Incorrect string length - got %d, want 123", l) + } + if l := len(C.GoString(C.dangerousString2())); l != 4096+123 { + t.Errorf("Incorrect string length - got %d, want %d", l, 4096+123) + } +} diff --git a/misc/cgo/test/issue24206_generic.go b/misc/cgo/test/issue24206_generic.go new file mode 100644 index 00000000000..27c4d65f28e --- /dev/null +++ b/misc/cgo/test/issue24206_generic.go @@ -0,0 +1,13 @@ +// +build !amd64 !linux + +// Copyright 2018 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 + +import "testing" + +func test24206(t *testing.T) { + t.Skip("Skipping on non-amd64 or non-linux system") +} diff --git a/misc/cgo/test/issue25143.go b/misc/cgo/test/issue25143.go new file mode 100644 index 00000000000..607bfe4ba0f --- /dev/null +++ b/misc/cgo/test/issue25143.go @@ -0,0 +1,22 @@ +// Copyright 2018 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 + +import "C" +import "testing" + +func issue25143sum(ns ...C.int) C.int { + total := C.int(0) + for _, n := range ns { + total += n + } + return total +} + +func test25143(t *testing.T) { + if got, want := issue25143sum(1, 2, 3), C.int(6); got != want { + t.Errorf("issue25143sum(1, 2, 3) == %v, expected %v", got, want) + } +} diff --git a/misc/cgo/test/issue4029.c b/misc/cgo/test/issue4029.c index eab36834501..7205c5a5a25 100644 --- a/misc/cgo/test/issue4029.c +++ b/misc/cgo/test/issue4029.c @@ -4,6 +4,25 @@ // +build !windows +#include +#include + +// Write our own versions of dlopen/dlsym/dlclose so that we represent +// the opaque handle as a Go uintptr rather than a Go pointer to avoid +// garbage collector confusion. See issue 23663. + +uintptr_t dlopen4029(char* name, int flags) { + return (uintptr_t)(dlopen(name, flags)); +} + +uintptr_t dlsym4029(uintptr_t handle, char* name) { + return (uintptr_t)(dlsym((void*)(handle), name)); +} + +int dlclose4029(uintptr_t handle) { + return dlclose((void*)(handle)); +} + void call4029(void *arg) { void (*fn)(void) = arg; fn(); diff --git a/misc/cgo/test/issue4029.go b/misc/cgo/test/issue4029.go index 5789b99ef67..8e468d367d1 100644 --- a/misc/cgo/test/issue4029.go +++ b/misc/cgo/test/issue4029.go @@ -7,10 +7,15 @@ package cgotest /* +#include #include #cgo linux LDFLAGS: -ldl -extern void call4029(void *arg); +extern uintptr_t dlopen4029(char*, int); +extern uintptr_t dlsym4029(uintptr_t, char*); +extern int dlclose4029(uintptr_t); + +extern void call4029(uintptr_t arg); */ import "C" @@ -51,15 +56,15 @@ func test4029(t *testing.T) { } func loadThySelf(t *testing.T, symbol string) { - this_process := C.dlopen(nil, C.RTLD_NOW) - if this_process == nil { + this_process := C.dlopen4029(nil, C.RTLD_NOW) + if this_process == 0 { t.Error("dlopen:", C.GoString(C.dlerror())) return } - defer C.dlclose(this_process) + defer C.dlclose4029(this_process) - symbol_address := C.dlsym(this_process, C.CString(symbol)) - if symbol_address == nil { + symbol_address := C.dlsym4029(this_process, C.CString(symbol)) + if symbol_address == 0 { t.Error("dlsym:", C.GoString(C.dlerror())) return } diff --git a/misc/cgo/test/issue9400/asm_arm.s b/misc/cgo/test/issue9400/asm_arm.s index 166d53f304e..96c278520f3 100644 --- a/misc/cgo/test/issue9400/asm_arm.s +++ b/misc/cgo/test/issue9400/asm_arm.s @@ -9,7 +9,7 @@ TEXT cas<>(SB),NOSPLIT,$0 MOVW $0xffff0fc0, R15 // R15 is PC -TEXT ·RewindAndSetgid(SB),NOSPLIT,$-4-0 +TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0 // Save link register MOVW R14, R4 diff --git a/misc/cgo/test/issue9400/asm_arm64.s b/misc/cgo/test/issue9400/asm_arm64.s index 9bb50816b44..2ebbfcca3b6 100644 --- a/misc/cgo/test/issue9400/asm_arm64.s +++ b/misc/cgo/test/issue9400/asm_arm64.s @@ -6,7 +6,7 @@ #include "textflag.h" -TEXT ·RewindAndSetgid(SB),NOSPLIT,$-8-0 +TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0 // Save link register MOVD R30, R9 diff --git a/misc/cgo/test/issue9400/asm_mipsx.s b/misc/cgo/test/issue9400/asm_mipsx.s index ddf33e9f8e5..7a927351942 100644 --- a/misc/cgo/test/issue9400/asm_mipsx.s +++ b/misc/cgo/test/issue9400/asm_mipsx.s @@ -7,7 +7,7 @@ #include "textflag.h" -TEXT ·RewindAndSetgid(SB),NOSPLIT,$-4-0 +TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0 // Rewind stack pointer so anything that happens on the stack // will clobber the test pattern created by the caller ADDU $(1024*8), R29 diff --git a/misc/cgo/test/sigprocmask.go b/misc/cgo/test/sigprocmask.go index 39b658e96c3..e2b939f05e2 100644 --- a/misc/cgo/test/sigprocmask.go +++ b/misc/cgo/test/sigprocmask.go @@ -32,7 +32,7 @@ func IntoGoAndBack() { func testSigprocmask(t *testing.T) { if r := C.RunSigThread(); r != 0 { - t.Error("pthread_create/pthread_join failed") + t.Errorf("pthread_create/pthread_join failed: %d", r) } if !blocked { t.Error("Go runtime unblocked SIGIO") diff --git a/misc/cgo/test/test22906.go b/misc/cgo/test/test22906.go new file mode 100644 index 00000000000..02bae9cfa7d --- /dev/null +++ b/misc/cgo/test/test22906.go @@ -0,0 +1,74 @@ +// 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. + +// +build cgo + +package cgotest + +/* + +// It's going to be hard to include a whole real JVM to test this. +// So we'll simulate a really easy JVM using just the parts we need. + +// This is the relevant part of jni.h. + +struct _jobject; + +typedef struct _jobject *jobject; +typedef jobject jclass; +typedef jobject jthrowable; +typedef jobject jstring; +typedef jobject jarray; +typedef jarray jbooleanArray; +typedef jarray jbyteArray; +typedef jarray jcharArray; +typedef jarray jshortArray; +typedef jarray jintArray; +typedef jarray jlongArray; +typedef jarray jfloatArray; +typedef jarray jdoubleArray; +typedef jarray jobjectArray; + +typedef jobject jweak; + +// Note: jvalue is already a non-pointer type due to it being a C union. + +*/ +import "C" +import ( + "testing" +) + +func test22906(t *testing.T) { + var x1 C.jobject = 0 // Note: 0, not nil. That makes sure we use uintptr for these types. + _ = x1 + var x2 C.jclass = 0 + _ = x2 + var x3 C.jthrowable = 0 + _ = x3 + var x4 C.jstring = 0 + _ = x4 + var x5 C.jarray = 0 + _ = x5 + var x6 C.jbooleanArray = 0 + _ = x6 + var x7 C.jbyteArray = 0 + _ = x7 + var x8 C.jcharArray = 0 + _ = x8 + var x9 C.jshortArray = 0 + _ = x9 + var x10 C.jintArray = 0 + _ = x10 + var x11 C.jlongArray = 0 + _ = x11 + var x12 C.jfloatArray = 0 + _ = x12 + var x13 C.jdoubleArray = 0 + _ = x13 + var x14 C.jobjectArray = 0 + _ = x14 + var x15 C.jweak = 0 + _ = x15 +} diff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go index 7ba5faabeb3..71232305f60 100644 --- a/misc/cgo/testcarchive/carchive_test.go +++ b/misc/cgo/testcarchive/carchive_test.go @@ -13,6 +13,7 @@ import ( "os" "os/exec" "path/filepath" + "regexp" "strings" "syscall" "testing" @@ -166,6 +167,28 @@ func testInstall(t *testing.T, exe, libgoa, libgoh string, buildcmd ...string) { t.Logf("%s", out) t.Fatal(err) } + + checkLineComments(t, libgoh) +} + +var badLineRegexp = regexp.MustCompile(`(?m)^#line [0-9]+ "/.*$`) + +// checkLineComments checks that the export header generated by +// -buildmode=c-archive doesn't have any absolute paths in the #line +// comments. We don't want those paths because they are unhelpful for +// the user and make the files change based on details of the location +// of GOPATH. +func checkLineComments(t *testing.T, hdrname string) { + hdr, err := ioutil.ReadFile(hdrname) + if err != nil { + if !os.IsNotExist(err) { + t.Error(err) + } + return + } + if line := badLineRegexp.Find(hdr); line != nil { + t.Errorf("bad #line directive with absolute path in %s: %q", hdrname, line) + } } func TestInstall(t *testing.T) { @@ -209,6 +232,7 @@ func TestEarlySignalHandler(t *testing.T) { t.Logf("%s", out) t.Fatal(err) } + checkLineComments(t, "libgo2.h") ccArgs := append(cc, "-o", "testp"+exeSuffix, "main2.c", "libgo2.a") if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil { @@ -238,6 +262,7 @@ func TestSignalForwarding(t *testing.T) { t.Logf("%s", out) t.Fatal(err) } + checkLineComments(t, "libgo2.h") ccArgs := append(cc, "-o", "testp"+exeSuffix, "main5.c", "libgo2.a") if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil { @@ -260,6 +285,9 @@ func TestSignalForwarding(t *testing.T) { } func TestSignalForwardingExternal(t *testing.T) { + if GOOS == "freebsd" { + t.Skipf("skipping on %s/%s; signal always goes to the Go runtime", GOOS, GOARCH) + } checkSignalForwardingTest(t) defer func() { @@ -275,6 +303,7 @@ func TestSignalForwardingExternal(t *testing.T) { t.Logf("%s", out) t.Fatal(err) } + checkLineComments(t, "libgo2.h") ccArgs := append(cc, "-o", "testp"+exeSuffix, "main5.c", "libgo2.a") if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil { @@ -387,6 +416,7 @@ func TestOsSignal(t *testing.T) { t.Logf("%s", out) t.Fatal(err) } + checkLineComments(t, "libgo3.h") ccArgs := append(cc, "-o", "testp"+exeSuffix, "main3.c", "libgo3.a") if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil { @@ -419,6 +449,7 @@ func TestSigaltstack(t *testing.T) { t.Logf("%s", out) t.Fatal(err) } + checkLineComments(t, "libgo4.h") ccArgs := append(cc, "-o", "testp"+exeSuffix, "main4.c", "libgo4.a") if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil { @@ -433,7 +464,7 @@ func TestSigaltstack(t *testing.T) { } const testar = `#!/usr/bin/env bash -while expr $1 : '[-]' >/dev/null; do +while [[ $1 == -* ]] >/dev/null; do shift done echo "testar" > $1 @@ -470,6 +501,7 @@ func TestExtar(t *testing.T) { t.Logf("%s", out) t.Fatal(err) } + checkLineComments(t, "libgo4.h") if _, err := os.Stat("testar.ran"); err != nil { if os.IsNotExist(err) { @@ -570,6 +602,7 @@ func TestSIGPROF(t *testing.T) { t.Logf("%s", out) t.Fatal(err) } + checkLineComments(t, "libgo6.h") ccArgs := append(cc, "-o", "testp6"+exeSuffix, "main6.c", "libgo6.a") if out, err := exec.Command(ccArgs[0], ccArgs[1:]...).CombinedOutput(); err != nil { @@ -608,6 +641,7 @@ func TestCompileWithoutShared(t *testing.T) { if err != nil { t.Fatal(err) } + checkLineComments(t, "libgo2.h") exe := "./testnoshared" + exeSuffix @@ -642,3 +676,50 @@ func TestCompileWithoutShared(t *testing.T) { t.Logf("%s", out) expectSignal(t, err, syscall.SIGPIPE) } + +// Test that installing a second time recreates the header files. +func TestCachedInstall(t *testing.T) { + defer os.RemoveAll("pkg") + + h1 := filepath.Join("pkg", libgodir, "libgo.h") + h2 := filepath.Join("pkg", libgodir, "p.h") + + buildcmd := []string{"go", "install", "-i", "-buildmode=c-archive", "libgo"} + + cmd := exec.Command(buildcmd[0], buildcmd[1:]...) + cmd.Env = gopathEnv + t.Log(buildcmd) + if out, err := cmd.CombinedOutput(); err != nil { + t.Logf("%s", out) + t.Fatal(err) + } + + if _, err := os.Stat(h1); err != nil { + t.Errorf("libgo.h not installed: %v", err) + } + if _, err := os.Stat(h2); err != nil { + t.Errorf("p.h not installed: %v", err) + } + + if err := os.Remove(h1); err != nil { + t.Fatal(err) + } + if err := os.Remove(h2); err != nil { + t.Fatal(err) + } + + cmd = exec.Command(buildcmd[0], buildcmd[1:]...) + cmd.Env = gopathEnv + t.Log(buildcmd) + if out, err := cmd.CombinedOutput(); err != nil { + t.Logf("%s", out) + t.Fatal(err) + } + + if _, err := os.Stat(h1); err != nil { + t.Errorf("libgo.h not installed in second run: %v", err) + } + if _, err := os.Stat(h2); err != nil { + t.Errorf("p.h not installed in second run: %v", err) + } +} diff --git a/misc/cgo/testcarchive/main5.c b/misc/cgo/testcarchive/main5.c index 2437bf07c58..897b70d2fa6 100644 --- a/misc/cgo/testcarchive/main5.c +++ b/misc/cgo/testcarchive/main5.c @@ -85,6 +85,8 @@ int main(int argc, char** argv) { printf("write(2) unexpectedly succeeded\n"); return 0; } + printf("did not receieve SIGPIPE\n"); + return 0; } default: printf("Unknown test: %d\n", test); diff --git a/misc/cgo/testcshared/cshared_test.go b/misc/cgo/testcshared/cshared_test.go index 49be0923966..77cefc5a66a 100644 --- a/misc/cgo/testcshared/cshared_test.go +++ b/misc/cgo/testcshared/cshared_test.go @@ -7,6 +7,7 @@ package cshared_test import ( "debug/elf" "fmt" + "io/ioutil" "log" "os" "os/exec" @@ -55,7 +56,8 @@ func TestMain(m *testing.M) { androiddir = fmt.Sprintf("/data/local/tmp/testcshared-%d", os.Getpid()) if GOOS == "android" { - cmd := exec.Command("adb", "shell", "mkdir", "-p", androiddir) + args := append(adbCmd(), "shell", "mkdir", "-p", androiddir) + cmd := exec.Command(args[0], args[1:]...) out, err := cmd.CombinedOutput() if err != nil { log.Fatalf("setupAndroid failed: %v\n%s\n", err, out) @@ -154,11 +156,19 @@ func cmdToRun(name string) string { return "./" + name + exeSuffix } +func adbCmd() []string { + cmd := []string{"adb"} + if flags := os.Getenv("GOANDROID_ADB_FLAGS"); flags != "" { + cmd = append(cmd, strings.Split(flags, " ")...) + } + return cmd +} + func adbPush(t *testing.T, filename string) { if GOOS != "android" { return } - args := []string{"adb", "push", filename, fmt.Sprintf("%s/%s", androiddir, filename)} + args := append(adbCmd(), "push", filename, fmt.Sprintf("%s/%s", androiddir, filename)) cmd := exec.Command(args[0], args[1:]...) if out, err := cmd.CombinedOutput(); err != nil { t.Fatalf("adb command failed: %v\n%s\n", err, out) @@ -169,7 +179,7 @@ func adbRun(t *testing.T, env []string, adbargs ...string) string { if GOOS != "android" { t.Fatalf("trying to run adb command when operating system is not android.") } - args := []string{"adb", "shell"} + args := append(adbCmd(), "shell") // Propagate LD_LIBRARY_PATH to the adb shell invocation. for _, e := range env { if strings.Index(e, "LD_LIBRARY_PATH=") != -1 { @@ -237,7 +247,7 @@ func createHeaders() error { } if GOOS == "android" { - args = []string{"adb", "push", libgoname, fmt.Sprintf("%s/%s", androiddir, libgoname)} + args = append(adbCmd(), "push", libgoname, fmt.Sprintf("%s/%s", androiddir, libgoname)) cmd = exec.Command(args[0], args[1:]...) out, err = cmd.CombinedOutput() if err != nil { @@ -270,7 +280,8 @@ func cleanupAndroid() { if GOOS != "android" { return } - cmd := exec.Command("adb", "shell", "rm", "-rf", androiddir) + args := append(adbCmd(), "shell", "rm", "-rf", androiddir) + cmd := exec.Command(args[0], args[1:]...) out, err := cmd.CombinedOutput() if err != nil { log.Fatalf("cleanupAndroid failed: %v\n%s\n", err, out) @@ -311,7 +322,11 @@ func TestExportedSymbolsWithDynamicLoad(t *testing.T) { createHeadersOnce(t) - runCC(t, "-o", cmd, "main1.c", "-ldl") + if GOOS != "freebsd" { + runCC(t, "-o", cmd, "main1.c", "-ldl") + } else { + runCC(t, "-o", cmd, "main1.c") + } adbPush(t, cmd) defer os.Remove(bin) @@ -400,7 +415,11 @@ func testSignalHandlers(t *testing.T, pkgname, cfile, cmd string) { "-o", libname, pkgname, ) adbPush(t, libname) - runCC(t, "-pthread", "-o", cmd, cfile, "-ldl") + if GOOS != "freebsd" { + runCC(t, "-pthread", "-o", cmd, cfile, "-ldl") + } else { + runCC(t, "-pthread", "-o", cmd, cfile) + } adbPush(t, cmd) bin := cmdToRun(cmd) @@ -477,3 +496,99 @@ func TestPIE(t *testing.T) { } } } + +// Test that installing a second time recreates the header files. +func TestCachedInstall(t *testing.T) { + tmpdir, err := ioutil.TempDir("", "cshared") + if err != nil { + t.Fatal(err) + } + // defer os.RemoveAll(tmpdir) + + copyFile(t, filepath.Join(tmpdir, "src", "libgo", "libgo.go"), filepath.Join("src", "libgo", "libgo.go")) + copyFile(t, filepath.Join(tmpdir, "src", "p", "p.go"), filepath.Join("src", "p", "p.go")) + + env := append(os.Environ(), "GOPATH="+tmpdir) + + buildcmd := []string{"go", "install", "-x", "-i", "-buildmode=c-shared", "-installsuffix", "testcshared", "libgo"} + + cmd := exec.Command(buildcmd[0], buildcmd[1:]...) + cmd.Env = env + t.Log(buildcmd) + out, err := cmd.CombinedOutput() + t.Logf("%s", out) + if err != nil { + t.Fatal(err) + } + + var libgoh, ph string + + walker := func(path string, info os.FileInfo, err error) error { + if err != nil { + t.Fatal(err) + } + var ps *string + switch filepath.Base(path) { + case "libgo.h": + ps = &libgoh + case "p.h": + ps = &ph + } + if ps != nil { + if *ps != "" { + t.Fatalf("%s found again", *ps) + } + *ps = path + } + return nil + } + + if err := filepath.Walk(tmpdir, walker); err != nil { + t.Fatal(err) + } + + if libgoh == "" { + t.Fatal("libgo.h not installed") + } + if ph == "" { + t.Fatal("p.h not installed") + } + + if err := os.Remove(libgoh); err != nil { + t.Fatal(err) + } + if err := os.Remove(ph); err != nil { + t.Fatal(err) + } + + cmd = exec.Command(buildcmd[0], buildcmd[1:]...) + cmd.Env = env + t.Log(buildcmd) + out, err = cmd.CombinedOutput() + t.Logf("%s", out) + if err != nil { + t.Fatal(err) + } + + if _, err := os.Stat(libgoh); err != nil { + t.Errorf("libgo.h not installed in second run: %v", err) + } + if _, err := os.Stat(ph); err != nil { + t.Errorf("p.h not installed in second run: %v", err) + } +} + +// copyFile copies src to dst. +func copyFile(t *testing.T, dst, src string) { + t.Helper() + data, err := ioutil.ReadFile(src) + if err != nil { + t.Fatal(err) + } + if err := os.MkdirAll(filepath.Dir(dst), 0777); err != nil { + t.Fatal(err) + } + if err := ioutil.WriteFile(dst, data, 0666); err != nil { + t.Fatal(err) + } +} diff --git a/misc/cgo/testcshared/main2.c b/misc/cgo/testcshared/main2.c index 6e8bf141caf..f89bcca474f 100644 --- a/misc/cgo/testcshared/main2.c +++ b/misc/cgo/testcshared/main2.c @@ -9,7 +9,7 @@ #include #include -#define fd (100) +#define fd (30) // Tests libgo2.so, which does not export any functions. // Read a string from the file descriptor and print it. @@ -21,7 +21,7 @@ int main(void) { // The descriptor will be initialized in a thread, so we have to // give a chance to get opened. - for (i = 0; i < 1000; i++) { + for (i = 0; i < 200; i++) { n = read(fd, buf, sizeof buf); if (n >= 0) break; @@ -33,7 +33,7 @@ int main(void) { // An EBADF error means that the shared library has not opened the // descriptor yet. ts.tv_sec = 0; - ts.tv_nsec = 1000000; + ts.tv_nsec = 10000000; nanosleep(&ts, NULL); } diff --git a/misc/cgo/testcshared/src/libgo2/libgo2.go b/misc/cgo/testcshared/src/libgo2/libgo2.go index 1b69d8f09fa..e57c93b77d7 100644 --- a/misc/cgo/testcshared/src/libgo2/libgo2.go +++ b/misc/cgo/testcshared/src/libgo2/libgo2.go @@ -21,7 +21,7 @@ import ( // that the C code can also use. const ( - fd = 100 + fd = 30 ) func init() { diff --git a/misc/cgo/testplugin/src/issue24351/main.go b/misc/cgo/testplugin/src/issue24351/main.go new file mode 100644 index 00000000000..4107adff7b4 --- /dev/null +++ b/misc/cgo/testplugin/src/issue24351/main.go @@ -0,0 +1,21 @@ +// Copyright 2018 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("issue24351.so") + if err != nil { + panic(err) + } + f, err := p.Lookup("B") + if err != nil { + panic(err) + } + c := make(chan bool) + f.(func(chan bool))(c) + <-c +} diff --git a/misc/cgo/testplugin/src/issue24351/plugin.go b/misc/cgo/testplugin/src/issue24351/plugin.go new file mode 100644 index 00000000000..db17e0a6097 --- /dev/null +++ b/misc/cgo/testplugin/src/issue24351/plugin.go @@ -0,0 +1,14 @@ +// Copyright 2018 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 "fmt" + +func B(c chan bool) { + go func() { + fmt.Println(1.5) + c <- true + }() +} diff --git a/misc/cgo/testplugin/test.bash b/misc/cgo/testplugin/test.bash index 18e3803bf42..df38204a4e9 100755 --- a/misc/cgo/testplugin/test.bash +++ b/misc/cgo/testplugin/test.bash @@ -85,3 +85,8 @@ GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -o issue22175 src/issue22175/main. GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -buildmode=plugin -o issue.22295.so issue22295.pkg GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -o issue22295 src/issue22295.pkg/main.go ./issue22295 + +# Test for issue 24351 +GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -buildmode=plugin -o issue24351.so src/issue24351/plugin.go +GOPATH=$(pwd) go build -gcflags "$GO_GCFLAGS" -o issue24351 src/issue24351/main.go +./issue24351 diff --git a/misc/cgo/testsanitizers/cc_test.go b/misc/cgo/testsanitizers/cc_test.go index cacb0d93df7..306844bdc80 100644 --- a/misc/cgo/testsanitizers/cc_test.go +++ b/misc/cgo/testsanitizers/cc_test.go @@ -407,7 +407,7 @@ func (d *tempDir) RemoveAll(t *testing.T) { return } if err := os.RemoveAll(d.base); err != nil { - t.Fatal("Failed to remove temp dir: %v", err) + t.Fatalf("Failed to remove temp dir: %v", err) } } diff --git a/misc/cgo/testshared/shared_test.go b/misc/cgo/testshared/shared_test.go index f1e8f0605b6..a2960057809 100644 --- a/misc/cgo/testshared/shared_test.go +++ b/misc/cgo/testshared/shared_test.go @@ -351,10 +351,10 @@ func readNotes(f *elf.File) ([]*note, error) { func dynStrings(t *testing.T, path string, flag elf.DynTag) []string { f, err := elf.Open(path) - defer f.Close() if err != nil { t.Fatalf("elf.Open(%q) failed: %v", path, err) } + defer f.Close() dynstrings, err := f.DynString(flag) if err != nil { t.Fatalf("DynString(%s) failed on %s: %v", flag, path, err) @@ -598,7 +598,6 @@ func TestThreeGopathShlibs(t *testing.T) { // If gccgo is not available or not new enough call t.Skip. Otherwise, // return a build.Context that is set up for gccgo. func prepGccgo(t *testing.T) build.Context { - t.Skip("golang.org/issue/22472") gccgoName := os.Getenv("GCCGO") if gccgoName == "" { gccgoName = "gccgo" @@ -648,8 +647,6 @@ func TestGoPathShlibGccgo(t *testing.T) { // library with gccgo, another GOPATH package that depends on the first and an // executable that links the second library. func TestTwoGopathShlibsGccgo(t *testing.T) { - t.Skip("golang.org/issue/22224") - gccgoContext := prepGccgo(t) libgoRE := regexp.MustCompile("libgo.so.[0-9]+") @@ -793,6 +790,7 @@ func TestRebuilding(t *testing.T) { // If the .a file is newer than the .so, the .so is rebuilt (but not the .a) t.Run("newarchive", func(t *testing.T) { resetFileStamps() + AssertNotRebuilt(t, "new .a file before build", filepath.Join(gopathInstallDir, "depBase.a")) goCmd(t, "list", "-linkshared", "-f={{.ImportPath}} {{.Stale}} {{.StaleReason}} {{.Target}}", "depBase") AssertNotRebuilt(t, "new .a file before build", filepath.Join(gopathInstallDir, "depBase.a")) cleanup := touch(t, filepath.Join(gopathInstallDir, "depBase.a")) diff --git a/misc/ios/README b/misc/ios/README index 417a217892c..83fa2d6fc70 100644 --- a/misc/ios/README +++ b/misc/ios/README @@ -1,44 +1,50 @@ Go on iOS ========= -To build a cross compiling toolchain for iOS on OS X, first modify clangwrap.sh -in misc/ios to match your setup. And then run: +For details on developing Go for iOS on macOS, see the documentation in the mobile +subrepository: - GOARM=7 CGO_ENABLED=1 GOARCH=arm CC_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh \ - CXX_FOR_TARGET=`pwd`/../misc/ios/clangwrap.sh ./make.bash + https://github.com/golang/mobile -To build a program, use the normal go build command: +It is necessary to set up the environment before running tests or programs directly on a +device. - CGO_ENABLED=1 GOARCH=arm go build import/path +First make sure you have a valid developer certificate and have setup your device properly +to run apps signed by your developer certificate. Then install the libimobiledevice and +ideviceinstaller tools from https://www.libimobiledevice.org/. Use the HEAD versions from +source; the stable versions have bugs that prevents the Go exec wrapper to install and run +apps. -To run a program on an iDevice, first make sure you have a valid developer -certificate and have setup your iDevice properly to run apps signed by your -developer certificate. Then install https://github.com/phonegap/ios-deploy. -At a first step, you can try building the famous hello world program to run -on your test device. -(The needed files are provided at https://github.com/minux/go-ios-examples.) +Second, the Go exec wrapper must be told the developer account signing identity, the team +id and a provisioned bundle id to use. They're specified with the environment variables +GOIOS_DEV_ID, GOIOS_TEAM_ID and GOIOS_APP_ID. The detect.go program in this directory will +attempt to auto-detect suitable values. Run it as - # assume your program binary is helloworld.go, build it into the - # example hello.app bundle. - CGO_ENABLED=1 GOARCH=arm go build -o hello.app/hello helloworld.go - # sign the executable using your developer certificate - codesign -f -s "iPhone Developer" --entitlements hello.app/Entitlements.plist hello.app/hello - # run the program inside lldb on iDevice, run `ios-deploy` for more - # command options - ios-deploy --debug --uninstall --bundle hello.app - # Depending on your ios-deploy version, you might need to enter "run" - # into lldb to run your program, and its output will be shown by lldb. + go run detect.go -Notes: - - A dummy hello.app bundle is provided in this directory to help you get started. - - Running the program on an iDevice requires code sign and thus external linking, - if your program uses cgo, then it will automatically use external linking. - However, if your program does not use cgo, please make sure to add - import _ "runtime/cgo" - so that external linking will be used. +which will output something similar to -Known issues -============ - - crypto/x509 won't build, I don't yet know how to get system root on iOS. - - Because I still want to be able to do native build, CGO_ENABLED=1 is not the - default, yet. + export GOIOS_DEV_ID="iPhone Developer: xxx@yyy.zzz (XXXXXXXX)" + export GOIOS_APP_ID=YYYYYYYY.some.bundle.id + export GOIOS_TEAM_ID=ZZZZZZZZ + +If you have multiple devices connected, specify the device UDID with the GOIOS_DEVICE_ID +variable. Use `idevice_id -l` to list all available UDIDs. + +Finally, to run the standard library tests, run iostest.bash with GOARCH set. For example, + + GOARCH=arm64 ./iostest.bash + +To use the go tool directly to run programs and tests, put $GOROOT/bin into PATH to ensure +the go_darwin_$GOARCH_exec wrapper is found. For example, to run the archive/tar tests + + export PATH=$GOROOT/bin:$PATH + GOARCH=arm64 go test archive/tar + +Note that the go_darwin_$GOARCH_exec wrapper uninstalls any existing app identified by +the bundle id before installing a new app. If the uninstalled app is the last app by +the developer identity, the device might also remove the permission to run apps from +that developer, and the exec wrapper will fail to install the new app. To avoid that, +install another app with the same developer identity but with a different bundle id. +That way, the permission to install apps is held on to while the primary app is +uninstalled. diff --git a/misc/ios/detect.go b/misc/ios/detect.go index 7e4e6f60e90..2594185c11e 100644 --- a/misc/ios/detect.go +++ b/misc/ios/detect.go @@ -14,6 +14,7 @@ package main import ( "bytes" + "crypto/x509" "fmt" "io/ioutil" "os" @@ -22,12 +23,14 @@ import ( ) func main() { - devID := detectDevID() + udids := getLines(exec.Command("idevice_id", "-l")) + if len(udids) == 0 { + fail("no udid found; is a device connected?") + } - udid := detectUDID() - mps := detectMobileProvisionFiles(udid) + mps := detectMobileProvisionFiles(udids) if len(mps) == 0 { - fail("did not find mobile provision matching device udid %s", udid) + fail("did not find mobile provision matching device udids %q", udids) } fmt.Println("Available provisioning profiles below.") @@ -35,7 +38,6 @@ func main() { 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() @@ -46,6 +48,12 @@ func main() { check(err) check(f.Close()) + cert, err := plistExtract(fname, "DeveloperCertificates:0") + check(err) + pcert, err := x509.ParseCertificate(cert) + check(err) + fmt.Printf("export GOIOS_DEV_ID=\"%s\"\n", pcert.Subject.CommonName) + appID, err := plistExtract(fname, "Entitlements:application-identifier") check(err) fmt.Printf("export GOIOS_APP_ID=%s\n", appID) @@ -56,39 +64,7 @@ func main() { } } -func detectDevID() string { - cmd := exec.Command("security", "find-identity", "-p", "codesigning", "-v") - lines := getLines(cmd) - - for _, line := range lines { - if !bytes.Contains(line, []byte("iPhone Developer")) { - continue - } - if bytes.Contains(line, []byte("REVOKED")) { - continue - } - fields := bytes.Fields(line) - return string(fields[1]) - } - fail("no code signing identity found") - panic("unreachable") -} - -var udidPrefix = []byte("UniqueDeviceID: ") - -func detectUDID() []byte { - cmd := exec.Command("ideviceinfo") - lines := getLines(cmd) - for _, line := range lines { - if bytes.HasPrefix(line, udidPrefix) { - return bytes.TrimPrefix(line, udidPrefix) - } - } - fail("udid not found; is the device connected?") - panic("unreachable") -} - -func detectMobileProvisionFiles(udid []byte) []string { +func detectMobileProvisionFiles(udids [][]byte) []string { cmd := exec.Command("mdfind", "-name", ".mobileprovision") lines := getLines(cmd) @@ -98,11 +74,17 @@ func detectMobileProvisionFiles(udid []byte) []string { continue } xmlLines := getLines(parseMobileProvision(string(line))) - for _, xmlLine := range xmlLines { - if bytes.Contains(xmlLine, udid) { - files = append(files, string(line)) + matches := 0 + for _, udid := range udids { + for _, xmlLine := range xmlLines { + if bytes.Contains(xmlLine, udid) { + matches++ + } } } + if matches == len(udids) { + files = append(files, string(line)) + } } return files } @@ -121,7 +103,12 @@ func plistExtract(fname string, path string) ([]byte, error) { func getLines(cmd *exec.Cmd) [][]byte { out := output(cmd) - return bytes.Split(out, []byte("\n")) + lines := bytes.Split(out, []byte("\n")) + // Skip the empty line at the end. + if len(lines[len(lines)-1]) == 0 { + lines = lines[:len(lines)-1] + } + return lines } func output(cmd *exec.Cmd) []byte { diff --git a/misc/ios/go_darwin_arm_exec.go b/misc/ios/go_darwin_arm_exec.go index 56dbb009a18..d1bf9fd150a 100644 --- a/misc/ios/go_darwin_arm_exec.go +++ b/misc/ios/go_darwin_arm_exec.go @@ -21,27 +21,26 @@ package main import ( "bytes" + "encoding/xml" "errors" - "flag" "fmt" "go/build" "io" "io/ioutil" "log" + "net" "os" "os/exec" + "os/signal" "path/filepath" "runtime" "strings" - "sync" "syscall" "time" ) const debug = false -var errRetry = errors.New("failed to start test harness (retry attempted)") - var tmpdir string var ( @@ -88,10 +87,28 @@ func main() { bundleID = parts[1] } + exitCode, err := runMain() + if err != nil { + log.Fatalf("%v\n", err) + } + os.Exit(exitCode) +} + +func runMain() (int, error) { var err error tmpdir, err = ioutil.TempDir("", "go_darwin_arm_exec_") if err != nil { - log.Fatal(err) + return 1, err + } + if !debug { + defer os.RemoveAll(tmpdir) + } + + appdir := filepath.Join(tmpdir, "gotest.app") + os.RemoveAll(appdir) + + if err := assembleApp(appdir, os.Args[1]); err != nil { + return 1, err } // This wrapper uses complicated machinery to run iOS binaries. It @@ -103,33 +120,43 @@ func main() { lockName := filepath.Join(os.TempDir(), "go_darwin_arm_exec-"+deviceID+".lock") lock, err = os.OpenFile(lockName, os.O_CREATE|os.O_RDONLY, 0666) if err != nil { - log.Fatal(err) + return 1, err } if err := syscall.Flock(int(lock.Fd()), syscall.LOCK_EX); err != nil { - log.Fatal(err) + return 1, err } - // Approximately 1 in a 100 binaries fail to start. If it happens, - // try again. These failures happen for several reasons beyond - // our control, but all of them are safe to retry as they happen - // before lldb encounters the initial getwd breakpoint. As we - // know the tests haven't started, we are not hiding flaky tests - // with this retry. - for i := 0; i < 5; i++ { - if i > 0 { - fmt.Fprintln(os.Stderr, "start timeout, trying again") - } - err = run(os.Args[1], os.Args[2:]) - if err == nil || err != errRetry { - break - } + + if err := uninstall(bundleID); err != nil { + return 1, err } - if !debug { - os.RemoveAll(tmpdir) + + if err := install(appdir); err != nil { + return 1, err } + + if err := mountDevImage(); err != nil { + return 1, err + } + + // Kill any hanging debug bridges that might take up port 3222. + exec.Command("killall", "idevicedebugserverproxy").Run() + + closer, err := startDebugBridge() if err != nil { - fmt.Fprintf(os.Stderr, "go_darwin_arm_exec: %v\n", err) - os.Exit(1) + return 1, err } + defer closer() + + if err := run(appdir, bundleID, os.Args[2:]); err != nil { + // If the lldb driver completed with an exit code, use that. + if err, ok := err.(*exec.ExitError); ok { + if ws, ok := err.Sys().(interface{ ExitStatus() int }); ok { + return ws.ExitStatus(), nil + } + } + return 1, err + } + return 0, nil } func getenv(envvar string) string { @@ -140,9 +167,7 @@ func getenv(envvar string) string { return s } -func run(bin string, args []string) (err error) { - appdir := filepath.Join(tmpdir, "gotest.app") - os.RemoveAll(appdir) +func assembleApp(appdir, bin string) error { if err := os.MkdirAll(appdir, 0755); err != nil { return err } @@ -182,285 +207,325 @@ func run(bin string, args []string) (err error) { if err := cmd.Run(); err != nil { return fmt.Errorf("codesign: %v", err) } + return nil +} - oldwd, err := os.Getwd() +// mountDevImage ensures a developer image is mounted on the device. +// The image contains the device lldb server for idevicedebugserverproxy +// to connect to. +func mountDevImage() error { + // Check for existing mount. + cmd := idevCmd(exec.Command("ideviceimagemounter", "-l", "-x")) + out, err := cmd.CombinedOutput() if err != nil { - return err + os.Stderr.Write(out) + return fmt.Errorf("ideviceimagemounter: %v", err) } - if err := os.Chdir(filepath.Join(appdir, "..")); err != nil { - return err + var info struct { + Dict struct { + Data []byte `xml:",innerxml"` + } `xml:"dict"` } - defer os.Chdir(oldwd) - - // Setting up lldb is flaky. The test binary itself runs when - // started is set to true. Everything before that is considered - // part of the setup and is retried. - started := false - defer func() { - if r := recover(); r != nil { - if w, ok := r.(waitPanic); ok { - err = w.err - if !started { - fmt.Printf("lldb setup error: %v\n", err) - err = errRetry - } - return - } - panic(r) - } - }() - - defer exec.Command("killall", "ios-deploy").Run() // cleanup - exec.Command("killall", "ios-deploy").Run() - - var opts options - opts, args = parseArgs(args) - - // ios-deploy invokes lldb to give us a shell session with the app. - s, err := newSession(appdir, args, opts) + if err := xml.Unmarshal(out, &info); err != nil { + return fmt.Errorf("mountDevImage: failed to decode mount information: %v", err) + } + dict, err := parsePlistDict(info.Dict.Data) if err != nil { - return err + return fmt.Errorf("mountDevImage: failed to parse mount information: %v", err) } - defer func() { - b := s.out.Bytes() - if err == nil && !debug { - i := bytes.Index(b, []byte("(lldb) process continue")) - if i > 0 { - b = b[i:] - } - } - os.Stdout.Write(b) - }() - - cond := func(out *buf) bool { - i0 := s.out.LastIndex([]byte("(lldb)")) - i1 := s.out.LastIndex([]byte("fruitstrap")) - 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 { - panic(waitPanic{err}) - } - - // Script LLDB. Oh dear. - s.do(`process handle SIGHUP --stop false --pass true --notify false`) - s.do(`process handle SIGPIPE --stop false --pass true --notify false`) - s.do(`process handle SIGUSR1 --stop false --pass true --notify false`) - s.do(`process handle SIGCONT --stop false --pass true --notify false`) - s.do(`process handle SIGSEGV --stop false --pass true --notify false`) // does not work - s.do(`process handle SIGBUS --stop false --pass true --notify false`) // does not work - - if opts.lldb { - _, err := io.Copy(s.in, os.Stdin) - if err != io.EOF { - return err - } + if dict["ImagePresent"] == "true" && dict["Status"] == "Complete" { return nil } - - started = true - - s.doCmd("run", "stop reason = signal SIGINT", 20*time.Second) - - startTestsLen := s.out.Len() - fmt.Fprintln(s.in, `process continue`) - - passed := func(out *buf) bool { - // Just to make things fun, lldb sometimes translates \n into \r\n. - 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 - } - err = s.wait("test completion", passed, opts.timeout) - if passed(s.out) { - // The returned lldb error code is usually non-zero. - // We check for test success by scanning for the final - // PASS returned by the test harness, assuming the worst - // in its absence. + // Some devices only give us an ImageSignature key. + if _, exists := dict["ImageSignature"]; exists { return nil } - return err -} - -type lldbSession struct { - cmd *exec.Cmd - in *os.File - out *buf - timedout chan struct{} - exited chan error -} - -func newSession(appdir string, args []string, opts options) (*lldbSession, error) { - lldbr, in, err := os.Pipe() + // No image is mounted. Find a suitable image. + imgPath, err := findDevImage() if err != nil { - return nil, err + return err } - s := &lldbSession{ - in: in, - out: new(buf), - exited: make(chan error), + sigPath := imgPath + ".signature" + cmd = idevCmd(exec.Command("ideviceimagemounter", imgPath, sigPath)) + if out, err := cmd.CombinedOutput(); err != nil { + os.Stderr.Write(out) + return fmt.Errorf("ideviceimagemounter: %v", err) } + return nil +} - iosdPath, err := exec.LookPath("ios-deploy") +// findDevImage use the device iOS version and build to locate a suitable +// developer image. +func findDevImage() (string, error) { + cmd := idevCmd(exec.Command("ideviceinfo")) + out, err := cmd.Output() if err != nil { - return nil, err + return "", fmt.Errorf("ideviceinfo: %v", err) } - cmdArgs := []string{ - // lldb tries to be clever with terminals. - // So we wrap it in script(1) and be clever - // right back at it. - "script", - "-q", "-t", "0", - "/dev/null", - - iosdPath, - "--debug", - "-u", - "-r", - "-n", - `--args=` + strings.Join(args, " ") + ``, - "--bundle", appdir, - } - if deviceID != "" { - cmdArgs = append(cmdArgs, "--id", deviceID) - } - s.cmd = exec.Command(cmdArgs[0], cmdArgs[1:]...) - if debug { - log.Println(strings.Join(s.cmd.Args, " ")) - } - - var out io.Writer = s.out - if opts.lldb { - out = io.MultiWriter(out, os.Stderr) - } - s.cmd.Stdout = out - s.cmd.Stderr = out // everything of interest is on stderr - s.cmd.Stdin = lldbr - - if err := s.cmd.Start(); err != nil { - return nil, fmt.Errorf("ios-deploy failed to start: %v", err) - } - - // Manage the -test.timeout here, outside of the test. There is a lot - // of moving parts in an iOS test harness (notably lldb) that can - // swallow useful stdio or cause its own ruckus. - if opts.timeout > 1*time.Second { - s.timedout = make(chan struct{}) - time.AfterFunc(opts.timeout-1*time.Second, func() { - close(s.timedout) - }) - } - - go func() { - s.exited <- s.cmd.Wait() - }() - - return s, nil -} - -func (s *lldbSession) do(cmd string) { s.doCmd(cmd, "(lldb)", 0) } - -func (s *lldbSession) doCmd(cmd string, waitFor string, extraTimeout time.Duration) { - startLen := s.out.Len() - fmt.Fprintln(s.in, cmd) - cond := func(out *buf) bool { - i := s.out.LastIndex([]byte(waitFor)) - return i > startLen - } - if err := s.wait(fmt.Sprintf("running cmd %q", cmd), cond, extraTimeout); err != nil { - panic(waitPanic{err}) - } -} - -func (s *lldbSession) wait(reason string, cond func(out *buf) bool, extraTimeout time.Duration) error { - doTimeout := 2*time.Second + extraTimeout - doTimedout := time.After(doTimeout) - for { - select { - case <-s.timedout: - if p := s.cmd.Process; p != nil { - p.Kill() - } - return fmt.Errorf("test timeout (%s)", reason) - case <-doTimedout: - if p := s.cmd.Process; p != nil { - p.Kill() - } - return fmt.Errorf("command timeout (%s for %v)", reason, doTimeout) - case err := <-s.exited: - return fmt.Errorf("exited (%s: %v)", reason, err) - default: - if cond(s.out) { - return nil - } - time.Sleep(20 * time.Millisecond) - } - } -} - -type buf struct { - mu sync.Mutex - buf []byte -} - -func (w *buf) Write(in []byte) (n int, err error) { - w.mu.Lock() - defer w.mu.Unlock() - w.buf = append(w.buf, in...) - return len(in), nil -} - -func (w *buf) LastIndex(sep []byte) int { - w.mu.Lock() - defer w.mu.Unlock() - return bytes.LastIndex(w.buf, sep) -} - -func (w *buf) Bytes() []byte { - w.mu.Lock() - defer w.mu.Unlock() - - b := make([]byte, len(w.buf)) - copy(b, w.buf) - return b -} - -func (w *buf) Len() int { - w.mu.Lock() - defer w.mu.Unlock() - return len(w.buf) -} - -type waitPanic struct { - err error -} - -type options struct { - timeout time.Duration - lldb bool -} - -func parseArgs(binArgs []string) (opts options, remainingArgs []string) { - var flagArgs []string - for _, arg := range binArgs { - if strings.Contains(arg, "-test.timeout") { - flagArgs = append(flagArgs, arg) - } - if strings.Contains(arg, "-lldb") { - flagArgs = append(flagArgs, arg) + var iosVer, buildVer string + lines := bytes.Split(out, []byte("\n")) + for _, line := range lines { + spl := bytes.SplitN(line, []byte(": "), 2) + if len(spl) != 2 { continue } - remainingArgs = append(remainingArgs, arg) + key, val := string(spl[0]), string(spl[1]) + switch key { + case "ProductVersion": + iosVer = val + case "BuildVersion": + buildVer = val + } } - f := flag.NewFlagSet("", flag.ContinueOnError) - f.DurationVar(&opts.timeout, "test.timeout", 10*time.Minute, "") - f.BoolVar(&opts.lldb, "lldb", false, "") - f.Parse(flagArgs) - return opts, remainingArgs + if iosVer == "" || buildVer == "" { + return "", errors.New("failed to parse ideviceinfo output") + } + verSplit := strings.Split(iosVer, ".") + if len(verSplit) > 2 { + // Developer images are specific to major.minor ios version. + // Cut off the patch version. + iosVer = strings.Join(verSplit[:2], ".") + } + sdkBase := "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport" + patterns := []string{fmt.Sprintf("%s (%s)", iosVer, buildVer), fmt.Sprintf("%s (*)", iosVer), fmt.Sprintf("%s*", iosVer)} + for _, pattern := range patterns { + matches, err := filepath.Glob(filepath.Join(sdkBase, pattern, "DeveloperDiskImage.dmg")) + if err != nil { + return "", fmt.Errorf("findDevImage: %v", err) + } + if len(matches) > 0 { + return matches[0], nil + } + } + return "", fmt.Errorf("failed to find matching developer image for iOS version %s build %s", iosVer, buildVer) +} +// startDebugBridge ensures that the idevicedebugserverproxy runs on +// port 3222. +func startDebugBridge() (func(), error) { + errChan := make(chan error, 1) + cmd := idevCmd(exec.Command("idevicedebugserverproxy", "3222")) + var stderr bytes.Buffer + cmd.Stderr = &stderr + if err := cmd.Start(); err != nil { + return nil, fmt.Errorf("idevicedebugserverproxy: %v", err) + } + go func() { + if err := cmd.Wait(); err != nil { + if _, ok := err.(*exec.ExitError); ok { + errChan <- fmt.Errorf("idevicedebugserverproxy: %s", stderr.Bytes()) + } else { + errChan <- fmt.Errorf("idevicedebugserverproxy: %v", err) + } + } + errChan <- nil + }() + closer := func() { + cmd.Process.Kill() + <-errChan + } + // Dial localhost:3222 to ensure the proxy is ready. + delay := time.Second / 4 + for attempt := 0; attempt < 5; attempt++ { + conn, err := net.DialTimeout("tcp", "localhost:3222", 5*time.Second) + if err == nil { + conn.Close() + return closer, nil + } + select { + case <-time.After(delay): + delay *= 2 + case err := <-errChan: + return nil, err + } + } + closer() + return nil, errors.New("failed to set up idevicedebugserverproxy") +} + +// findDeviceAppPath returns the device path to the app with the +// given bundle ID. It parses the output of ideviceinstaller -l -o xml, +// looking for the bundle ID and the corresponding Path value. +func findDeviceAppPath(bundleID string) (string, error) { + cmd := idevCmd(exec.Command("ideviceinstaller", "-l", "-o", "xml")) + out, err := cmd.CombinedOutput() + if err != nil { + os.Stderr.Write(out) + return "", fmt.Errorf("ideviceinstaller: -l -o xml %v", err) + } + var list struct { + Apps []struct { + Data []byte `xml:",innerxml"` + } `xml:"array>dict"` + } + if err := xml.Unmarshal(out, &list); err != nil { + return "", fmt.Errorf("failed to parse ideviceinstaller output: %v", err) + } + for _, app := range list.Apps { + values, err := parsePlistDict(app.Data) + if err != nil { + return "", fmt.Errorf("findDeviceAppPath: failed to parse app dict: %v", err) + } + if values["CFBundleIdentifier"] == bundleID { + if path, ok := values["Path"]; ok { + return path, nil + } + } + } + return "", fmt.Errorf("failed to find device path for bundle: %s", bundleID) +} + +// Parse an xml encoded plist. Plist values are mapped to string. +func parsePlistDict(dict []byte) (map[string]string, error) { + d := xml.NewDecoder(bytes.NewReader(dict)) + values := make(map[string]string) + var key string + var hasKey bool + for { + tok, err := d.Token() + if err == io.EOF { + break + } + if err != nil { + return nil, err + } + if tok, ok := tok.(xml.StartElement); ok { + if tok.Name.Local == "key" { + if err := d.DecodeElement(&key, &tok); err != nil { + return nil, err + } + hasKey = true + } else if hasKey { + var val string + var err error + switch n := tok.Name.Local; n { + case "true", "false": + // Bools are represented as and . + val = n + err = d.Skip() + default: + err = d.DecodeElement(&val, &tok) + } + if err != nil { + return nil, err + } + values[key] = val + hasKey = false + } else { + if err := d.Skip(); err != nil { + return nil, err + } + } + } + } + return values, nil +} + +func uninstall(bundleID string) error { + cmd := idevCmd(exec.Command( + "ideviceinstaller", + "-U", bundleID, + )) + if out, err := cmd.CombinedOutput(); err != nil { + os.Stderr.Write(out) + return fmt.Errorf("ideviceinstaller -U %q: %s", bundleID, err) + } + return nil +} + +func install(appdir string) error { + attempt := 0 + for { + cmd := idevCmd(exec.Command( + "ideviceinstaller", + "-i", appdir, + )) + if out, err := cmd.CombinedOutput(); err != nil { + // Sometimes, installing the app fails for some reason. + // Give the device a few seconds and try again. + if attempt < 5 { + time.Sleep(5 * time.Second) + attempt++ + continue + } + os.Stderr.Write(out) + return fmt.Errorf("ideviceinstaller -i %q: %v (%d attempts)", appdir, err, attempt) + } + return nil + } +} + +func idevCmd(cmd *exec.Cmd) *exec.Cmd { + if deviceID != "" { + // Inject -u device_id after the executable, but before the arguments. + args := []string{cmd.Args[0], "-u", deviceID} + cmd.Args = append(args, cmd.Args[1:]...) + } + return cmd +} + +func run(appdir, bundleID string, args []string) error { + var env []string + for _, e := range os.Environ() { + // Don't override TMPDIR on the device. + if strings.HasPrefix(e, "TMPDIR=") { + continue + } + env = append(env, e) + } + attempt := 0 + for { + // The device app path reported by the device might be stale, so retry + // the lookup of the device path along with the lldb launching below. + deviceapp, err := findDeviceAppPath(bundleID) + if err != nil { + // The device app path might not yet exist for a newly installed app. + if attempt == 5 { + return err + } + attempt++ + time.Sleep(5 * time.Second) + continue + } + lldb := exec.Command( + "python", + "-", // Read script from stdin. + appdir, + deviceapp, + ) + lldb.Args = append(lldb.Args, args...) + lldb.Env = env + lldb.Stdin = strings.NewReader(lldbDriver) + lldb.Stdout = os.Stdout + var out bytes.Buffer + lldb.Stderr = io.MultiWriter(&out, os.Stderr) + err = lldb.Start() + if err == nil { + // Forward SIGQUIT to the lldb driver which in turn will forward + // to the running program. + sigs := make(chan os.Signal, 1) + signal.Notify(sigs, syscall.SIGQUIT) + proc := lldb.Process + go func() { + for sig := range sigs { + proc.Signal(sig) + } + }() + err = lldb.Wait() + signal.Stop(sigs) + close(sigs) + } + // If the program was not started it can be retried without papering over + // real test failures. + started := bytes.HasPrefix(out.Bytes(), []byte("lldb: running program")) + if started || err == nil || attempt == 5 { + return err + } + // Sometimes, the app was not yet ready to launch or the device path was + // stale. Retry. + attempt++ + time.Sleep(5 * time.Second) + } } func copyLocalDir(dst, src string) error { @@ -656,3 +721,91 @@ const resourceRules = ` ` + +const lldbDriver = ` +import sys +import os +import signal + +exe, device_exe, args = sys.argv[1], sys.argv[2], sys.argv[3:] + +env = [] +for k, v in os.environ.items(): + env.append(k + "=" + v) + +sys.path.append('/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python') + +import lldb + +debugger = lldb.SBDebugger.Create() +debugger.SetAsync(True) +debugger.SkipLLDBInitFiles(True) + +err = lldb.SBError() +target = debugger.CreateTarget(exe, None, 'remote-ios', True, err) +if not target.IsValid() or not err.Success(): + sys.stderr.write("lldb: failed to setup up target: %s\n" % (err)) + sys.exit(1) + +target.modules[0].SetPlatformFileSpec(lldb.SBFileSpec(device_exe)) + +listener = debugger.GetListener() +process = target.ConnectRemote(listener, 'connect://localhost:3222', None, err) +if not err.Success(): + sys.stderr.write("lldb: failed to connect to remote target: %s\n" % (err)) + sys.exit(1) + +# Don't stop on signals. +sigs = process.GetUnixSignals() +for i in range(0, sigs.GetNumSignals()): + sig = sigs.GetSignalAtIndex(i) + sigs.SetShouldStop(sig, False) + sigs.SetShouldNotify(sig, False) + +event = lldb.SBEvent() +running = False +prev_handler = None +while True: + if not listener.WaitForEvent(1, event): + continue + if not lldb.SBProcess.EventIsProcessEvent(event): + continue + if running: + # Pass through stdout and stderr. + while True: + out = process.GetSTDOUT(8192) + if not out: + break + sys.stdout.write(out) + while True: + out = process.GetSTDERR(8192) + if not out: + break + sys.stderr.write(out) + state = process.GetStateFromEvent(event) + if state in [lldb.eStateCrashed, lldb.eStateDetached, lldb.eStateUnloaded, lldb.eStateExited]: + if running: + signal.signal(signal.SIGQUIT, prev_handler) + break + elif state == lldb.eStateConnected: + process.RemoteLaunch(args, env, None, None, None, None, 0, False, err) + if not err.Success(): + sys.stderr.write("lldb: failed to launch remote process: %s\n" % (err)) + process.Kill() + debugger.Terminate() + sys.exit(1) + # Forward SIGQUIT to the program. + def signal_handler(signal, frame): + process.Signal(signal) + prev_handler = signal.signal(signal.SIGQUIT, signal_handler) + # Tell the Go driver that the program is running and should not be retried. + sys.stderr.write("lldb: running program\n") + running = True + # Process stops once at the beginning. Continue. + process.Continue() + +exitStatus = process.GetExitStatus() +process.Kill() +debugger.Terminate() +sys.exit(exitStatus) +` diff --git a/misc/nacl/testdata/mime.types b/misc/nacl/testdata/mime.types index 2c41bd2c005..81a415e9e66 100644 --- a/misc/nacl/testdata/mime.types +++ b/misc/nacl/testdata/mime.types @@ -9,7 +9,7 @@ # content languages and encodings, so choose them carefully. # # Internet media types should be registered as described in RFC 4288. -# The registry is at . +# The registry is at . # # MIME type (lowercased) Extensions # ============================================ ========== diff --git a/misc/trace/README.md b/misc/trace/README.md index 2e8bb057d4c..2f8958df5be 100644 --- a/misc/trace/README.md +++ b/misc/trace/README.md @@ -1,8 +1,8 @@ This directory contains helper file for trace viewer (`go tool trace`). -`trace_viewer_lean.html` was generated by following +`trace_viewer_full.html` was generated by following [instructions](https://github.com/catapult-project/catapult/blob/master/tracing/docs/embedding-trace-viewer.md) -on revision `623a005a3ffa9de13c4b92bc72290e7bcd1ca591` +on revision `dc970d3e1f7b3da5a2849de70ff253acdb70148f` of [catapult](https://github.com/catapult-project/catapult) using: ``` catapult$ ./tracing/bin/vulcanize_trace_viewer --config=full diff --git a/misc/trace/trace_viewer_full.html b/misc/trace/trace_viewer_full.html index f0d2e60b185..ba9dcc66529 100644 --- a/misc/trace/trace_viewer_full.html +++ b/misc/trace/trace_viewer_full.html @@ -99,12 +99,7 @@ - +