golang

copy from GoLang
兄Die,写代码太累了?孤独寂寞冷?还没有女朋友吧?
关注微信公众号(瓠悠笑软件部落),送知识!送知识!送温暖!送工作!送女朋友!插科打诨哟!
huyouxiao.com

The Go Blog

Participate in the 2017 Go User Survey

16 November 2017

The Go project wants to hear from you (again)!

Last year we conducted the first ever Go user survey. Thanks to all of you, it was an overwhelming success with over 3500 responses. The survey provided key insights and helped us better plan and prioritize.

We invite you to participate in the 2017 Go User Survey.

The Go User Survey

Who: If you currently use Go, have used Go in the past, or have any interest in the language, please help by sharing your feedback to improve Go for you and your fellow Gophers.

Where: Please take this 15-minute survey by Friday December 8th: 2017 Go User Survey

The survey is anonymous and confidential.

Why: The Go project leadership depends on your feedback to guide the future of the Go project. Your responses will help to understand what’s going well and what’s not, as well as help us prioritize improvements for the Go language, libraries and tools.

A few weeks after the survey closes, we will publish the anonymous aggregate results to the Go blog. See the 2016 Go user survey results to learn what insights were gained from last year’s survey.

Spread the word!

Please help us spread the word by sharing this post on your social network feeds, at meetups, around your office and in other communities.

By Steve Francia

Eight years of Go

10 November 2017

Today we celebrate 8 years since Go was released as an open source project. During Go’s 4th anniversary, Andrew finished the post with “Here’s to four more years!”. Now that we have reached that milestone, I cannot help but reflect on how much the project and ecosystem has grown since then. In our post 4 years ago we included a chart demonstrating Go’s rising popularity on Google Trends with the search term “golang”. Today, we’re including an updated chart. In this relative scale of popularity, what was 100 four years ago is now a mere 17. Go’s popularity has increased exponentially over the last 8 years and continues to grow.

Source: trends.google.com

Developers love Go

Go has been embraced by developers all over the world with approximately one million users worldwide. In the freshly published 2017 Octoverse by GitHub, Go has become the #9 most popular language, surpassing C. Go is the fastest growing language on GitHub in 2017 in the top 10 with 52% growth over the previous year. In growth, Go swapped places with Javascript, which fell to the second spot with 44%.

Source: octoverse.github.com

In Stack Overflow’s 2017 developer survey , Go was the only language that was both on the top 5 most loved and top 5 most wanted languages. People who use Go, love it, and the people who aren’t using Go, want to be.

Source: insights.stackoverflow.com/survey/2017

Go: The language of Cloud Infrastructure

In 2014, analyst Donnie Berkholz called Go the emerging language of cloud infrastructure. By 2017, Go has emerged as the language of cloud infrastructure. Today, every single cloud company has critical components of their cloud infrastructure implemented in Go including Google Cloud, AWS, Microsoft Azure, Digital Ocean, Heroku and many others. Go is a key part of cloud companies like Alibaba, Cloudflare, and Dropbox. Go is a critical part of open infrastructure including Kubernetes, Cloud Foundry, Openshift, NATS, Docker, Istio, Etcd, Consul, Juju and many more. Companies are increasingly choosing Go to build cloud infrastructure solutions.

Go’s Great Community

It may be hard to imagine that only four years ago the Go community was transitioning from online-only to include in-person community with its first conference. Now the Go community has had over 30 conferences all around the world with hundreds of presentations and tens of thousands of attendees. There are hundreds of Go meetups meeting monthly covering much of the globe. Wherever you live, you are likely to find a Go meetup nearby.

Two different organizations have been established to help with inclusivity in the Go community, Go Bridge and Women Who Go; the latter has grown to over 25 chapters. Both have been instrumental in offering free trainings. In 2017 alone over 50 scholarships to conferences have been given through efforts of Go Bridge and Women Who Go.

This year we had two significant firsts for the Go project. We had our first contributor summit where people from across the Go community came together to discuss the needs and future of the Go project. Shortly after, we had the first Go contributor workshop where hundreds of people came to make their first Go contribution.

Photo by Sameer Ajmani

Go’s impact on open source

Go has become a major force in the world of open source powering some of the most popular projects and enabling innovations across many industries. Find thousands of additional applications and libraries at awesome-go. Here are just a handful of the most popular:

Moby (formerly Docker) is a tool for packaging and running applications in lightweight containers. Its creator Solomon Hykes cited Go’s standard library, concurrency primitives, and ease of deployment as key factors, and said “To put it simply, if Docker had not been written in Go, it would not have been as successful.”
Kubernetes is a system for automating deployment, scaling and management of containerized applications. Initially designed by Google and used in the Google cloud, Kubernetes now is a critical part of every major cloud offering.
Hugo is now the most popular open-source static website engine. With its amazing speed and flexibility, Hugo makes building websites fun again. According to w3techs, Hugo now has nearly 3x the usage of Jekyll, the former leader.
Prometheus is an open source monitoring solution and time series database that powers metrics and alerting designed to be the system you go to during an outage to allow you to quickly diagnose problems.
Grafana is an open source, feature-rich metrics dashboard and graph editor for Graphite, Elasticsearch, OpenTSDB, Prometheus and InfluxDB.
Lantern delivers fast, reliable and secure access to blocked websites and apps.
Syncthing is an open-source cross platform peer-to-peer continuous file synchronization application
Keybase is a new and free security app for mobile phones and computers. Think of it as an open source Dropbox & Slack with end-to-end encryption public-key cryptography.
Fzf is an interactive Unix filter for command-line that can be used with any list; files, command history, processes, hostnames, bookmarks, git commits, etc. Fzf supports Unix, macOS and has beta support for Windows. It also can operate as a vim plugin.
Many of these authors have said that their projects would not exist without Go. Some like Kubernetes and Docker created entirely new solutions. Others like Hugo, Syncthing and Fzf created more refined experiences where many solutions already existed. The popularity of these applications alone is proof that Go is a ideal language for a broad set of use cases.

Thank You

This is the eighth time we have had the pleasure of writing a birthday blog post for Go and we continue to be overwhelmed by and grateful for the enthusiasm and support of the Go community.

Since Go was first open sourced we have had 10 releases of the language, libraries and tooling with more than 1680 contributors making over 50,000 commits to the project’s 34 repositories; More than double the number of contributors and nearly double the number of commits from only two years ago. This year we announced that we have begun planning Go 2, our first major revision of the language and tooling.

The Go team would like to thank everyone who has contributed to the project, whether you participate by contributing changes, reporting bugs, sharing your expertise in design discussions, writing blog posts or books, running events, attending or speaking at events, helping others learn or improve, open sourcing Go packages you wrote, contributing artwork, introducing Go to someone, or being part of the Go community. Without you, Go would not be as complete, useful, or successful as it is today.

Thank you, and here’s to eight more years!

By Steve Francia

Community Outreach Working Group

5 September 2017

Announcing the Go Community Outreach Working Group

The Go project has grown considerably with over half a million users and community members all over the world. To date all community oriented activities have been organized by the community with minimal involvement from the Go project. We greatly appreciate these efforts.

After talking to many community organizers we have heard consistent feedback that they would like better collaboration between organizers and the Go project. We are forming the Community outreach Working Group (CWG) to help support these community efforts.

The CWG Mission

The mission of the CWG is to act as a conduit between the broader Go community, it’s organizers and the Go project. The CWG will help provide the structures and community management necessary to create an online and in person community that is enjoyable and rewarding to participate in. The CWG leadership represents the Go project in these efforts.

The CWG is responsible for:

Defining programs to facilitate deeper collaboration across the community.
Facilitating the coordination of Go events
Establishing growth and expansion plans for the community
Project exposure and accessibility
Ecosystem Development
Leadership:

Ashley McNamara
Cassandra Salisbury
Francesc Campoy
Steve Francia
Plans for Action

The CWG has an open GitHub repo we’ve created for complete transparency of our efforts. We have various GitHub projects which are acting as our primary initiatives. Each project has a variety of issues tied to them with assignees from our Leadership team and our members.

If you’d like to get involved, we encourage you to comment on the issue that interests you or submit an issue yourself!

By Steve Francia & Cassandra Salisbury

Go 1.9 is released

24 August 2017

Today the Go team is happy to announce the release of Go 1.9. You can get it from the download page. There are many changes to the language, standard library, runtime, and tooling. This post covers the most significant visible ones. Most of the engineering effort put into this release went to improvements of the runtime and tooling, which makes for a less exciting announcement, but nonetheless a great release.

The most important change to the language is the introduction of type aliases: a feature created to support gradual code repair. A type alias declaration has the form:

type T1 = T2
This declaration introduces an alias name T1 for the type T2, in the same way that byte has always been an alias for uint8. The type alias design document and an article on refactoring cover this addition in more detail.

The new math/bits package provides bit counting and manipulation functions for unsigned integers, implemented by special CPU instructions when possible. For example, on x86-64 systems, bits.TrailingZeros(x) uses the BSF instruction.

The sync package has added a new Map type, safe for concurrent access. You can read more about it from its documentation and learn more about why it was created from this GopherCon 2017 lightning talk (slides). It is not a general replacement for Go’s map type; please see the documentation to learn when it should be used.

The testing package also has an addition. The new Helper method, added to both testing.T and testing.B, marks the calling function as a test helper function. When the testing package prints file and line information, it shows the location of the call to a helper function instead of a line in the helper function itself.

For example, consider this test:

package p

import “testing”

func failure(t *testing.T) {
t.Helper() // This call silences this function in error reports.
t.Fatal(“failure”)
}

func Test(t *testing.T) {
failure(t)
}
Because failure identifies itself as a test helper, the error message printed during Test will indicate line 11, where failure is called, instead of line 7, where failure calls t.Fatal.

The time package now transparently tracks monotonic time in each Time value, making computing durations between two Time values a safe operation in the presence of wall clock adjustments. For example, this code now computes the right elapsed time even across a leap second clock reset:

start := time.Now()
f()
elapsed := time.Since(start)
See the package docs and design document for details.

Finally, as part of the efforts to make the Go compiler faster, Go 1.9 compiles functions in a package concurrently.

Go 1.9 includes many more additions, improvements, and fixes. Find the complete set of changes, and more information about the improvements listed above, in the Go 1.9 release notes.

To celebrate the release, Go User Groups around the world are holding release parties.

By Francesc Campoy

Contribution Workshop

9 August 2017

Event Overview

by Steve

During the community day at GopherCon, the Go team held two workshops where we worked with people to help them make their first contribution to the Go project. This was the first time the Go project has ever attempted anything like this. We had about 140 participants and about 35 people who volunteered as mentors. Mentors not only received warm fuzzy feelings for helping others, but also a very stylish Go Mentor trucker hat. We had contributors of all ages and experience levels coming from North and South America, Africa, Europe, Asia, and Australia. It was truly a worldwide effort of Gophers coming together at GopherCon.

One of our reasons for running the workshop was for it to act as a forcing function to make us improve our contributor experience. In preparation for the workshop, we rewrote our contributor guide, including adding a “troubleshooting” section and built a tool go-contrib-init, which automated the process of setting up a development environment to be able to contribute to Go.

For the workshop itself, we developed a presentation “Contributing to Go,” and a dashboard / scoreboard that was presented during the event. The scoreboard was designed to encourage us all to work together towards a common goal of seeing our collective score increase. Participants added 1, 2 or 3 points to the total score when they performed actions like registering an account, making a change list (also known as a CL, similar to a pull request), amending a CL, or submitting a CL.

Brad Fitzpatrick, who stayed home from GopherCon this year, was ready and waiting to review all CLs submitted. He was so quick to review that many people thought he was an automated bot. Internally our team is now calling him “BradBot” mostly because we are in awe and a bit jealous.

Impact

We had a total of 65 CLs submitted from the people who participated in the workshop (within a week of the workshop). Of these, 44 were from contributors who had never previously contributed to any of the repos in the Go project. Half (22) of these contributions were already merged. Many of the others are waiting on the codebase to thaw as we are in the middle of a freeze for the upcoming 1.9 release. In addition to CLs, many contributed to the project in the form of bug reports, gardening tasks, and other types of contributions.

The most common type of contribution was an example function to be used in the documentation. The Go User survey identified that our documentation was significantly lacking examples. In the presentation, we asked users to find a package they loved and to add an example. In the Go project, examples are written as code in Go files (with specific naming) and the go doc tool displays them along side the documentation. This is a perfect first contribution as it’s something that can be merged during a freeze, it’s of critical importance to our users, and it’s an addition that has a relatively narrow scope.

One of the examples added is that of creating a Stringer, one of the more widely used interfaces in Go. CL 49270

In addition to examples, many people contributed critical bug fixes including:

CL 48988 fixing issue #21029
CL 49050 fixing issue #20054
CL 49031 fixing issue #20166
CL 49170 fixing issue #20877
Some people even surprised us by arriving with a bug in mind that they wanted to fix. Nikhita arrived ready to tackle issue #20786 and she did submitting CL 48871, after which she tweeted:

Not only were some great improvements made, but most importantly, we narrowed the gap between the core Go team and the broader community members. Many people on the Go team remarked that the community members were teaching them things about the Go project. People in the community (in person, and on Twitter) remarked that felt welcome to participate in the project.

Future

The event was successful well beyond our expectations. Sameer Ajmani, Go team manager said, “The contributor workshop was incredibly fun and educational–for the Go team. We cringed as users hit the rough edges in our process, and celebrated when they got up on the dashboard. The cheer when the group score hit 1000 was awesome.”

We are looking into ways to make this workshop easier to run for future events (like meetups and conferences). Our biggest challenge is providing enough mentorship so that users feel supported. If you have any ideas or would like to help with this process please let me know.

I’ve asked a few participants of the event to share their experiences below:

My Contribution Experience

by Cassandra

When I heard about the go-contrib workshop I was very excited and then I was extremely intimidated. I was encouraged by a member of the Go team to participate, so I thought what the heck.

As I walked into the room (let’s be real, I ran into the room because I was running late) I was pleased to see the room was jam-packed. I looked around for people in Gopher caps, which was the main indicator they were teachers. I sat down at one of the 16 round tables that had two hats and three non-hats. Brought up my screen and was ready to roll…

Jess Frazelle stood up and started the presentation and provided the group with a link to make it easy to follow.

The murmurs grew from a deep undercurrent to a resounding melody of voices, people were getting their computers set up with Go, they were skipping ahead to make sure their GOPATH was set, and were… wait what’s Gerrit?

Most of us had to get a little intro to Gerrit. I had no clue what it was, but luckily there was a handy slide. Jess explained that it was an alternative to GitHub with slightly more advanced code review tools. We then went through GitHub vs Geritt terminology, so we had better understanding of the process.

Ok, now it was time to become a freaking* Go contributor*.

To make this more exciting than it already is, the Go team set up a game where we could track as a group how many points we could rack up based on the Gerrit score system.

Seeing your name pop up on the board and listening to everyone’s excitement was intoxicating. It also invoked a sense of teamwork that lead to a feeling of inclusion and feeling like you were truly a part of the Go community.

In 6 steps a room of around 80 people were able to learn how to contribute to go within an hour. That’s a feat!

It wasn’t nearly as difficult as I anticipated and it wasn’t out of scope for a total newbie. It fostered a sense of community in an active and tangible way as well as a sense of inclusion in the illustrious process of Go contributions.

I’d personally like to thank the Go Team, the Gopher mentors in hats, and my fellow participants for making it one of my most memorable moments at GopherCon.

My Contribution Experience

by Matt

I’ve always found programming languages to be intimidating. It’s the code that enables the world to write code. Given the impact, surely smarter people than me should be working on it… but that fear was something to overcome. So when the opportunity to join a workshop to contribute to my new favorite programming language came up, I was excite to see how I could and how I could help. A month later, I’m now certain that anyone and everyone can (and should) contribute back to Go.

Here are my very verbose steps to go from 0 to 2 contributions to Go:

The Setup

Given Go’s use of Gerrit, I started by setting up my environment for it. Jess Frazzelle’s guide is a great place to start to not miss a step.

The real fun starts when you clone the Go repo. Ironically, you don’t hack on Go under $GOPATH, so I put it in my other workspace (which is ~/Develop).

cd $DEV # That’s my source code folder outside of $GOPATH
git clone --depth 1 https://go.googlesource.com/go
Then install the handy dandy helper tool, go-contrib-init:

go get -u golang.org/x/tools/cmd/go-contrib-init
Now you can run go-contrib-init from the go/ folder we cloned above and see whether or not we’re ready to contribute. But hold on if you’re following along, you’re not ready just yet.

Next, install codereview so you can participate in a Gerrit code review:

go get -u golang.org/x/review/git-codereview
This package includes git change and git mail which will replace your normal workflow of git commit and git push respectively.

Okay, installations are out of the way. Now setup your Gerrit account here, then sign the CLA appropriate for you (I signed a personal one for all Google projects, but choose the right option for you. You can see all CLAs you’ve signed at cla.developers.google.com/clas).

AND BAM. You’re good (to go)! But where to contribute?

Contributing

In the workshop, they sent us into the scratch repository, which is a safe place to fool around in order to master the workflow:

cd $(go env GOPATH)/src/golang.org/x
git clone --depth 1 [[https://go.googlesource.com/scratch][go.googlesource.com/scratch]]
First stop is to cd in and run go-contrib-init to make sure you’re ready to contribute:

go-contrib-init
All good. Happy hacking!
From there, I made a folder named after my GitHub account, did a git add -u then took git change for a spin. It has a hash that keeps track of your work, which is the one line you shouldn’t touch. Other than that, it feels just like git commit. Once I got the commit message matching the format of package: description (description begins with a lowercase), I used git mail to send it over to Gerrit.

Two good notes to take at this point: git change also works like git commit --amend, so if you need to update your patch you can add then change and it will all link to the same patch. Secondly, you can always review your patch from your personal Gerrit dashboard.

After a few back and forths, I officially had a contribute to Go! And if Jaana is right, it might be the first with emojis ✌️.

Contributing, For Real

The scratch repo is fun and all, but there’s a ton of ways to get into the depths of Go’s packages and give back. It’s at this point where I cruised around the many packages available to see what was available and interesting to me. And by “cruised around” I mean attempted to find a list of packages, then went to my source code to see what’s around under the go/src/ folder:

I decided to see what I can do in the regexp package, maybe out of love and fear of regex. Here’s where I switched to the website’s view of the package (it’s good to know that each standard package can be found at https://godoc.org/$PACKAGENAME). In there I noticed that QuoteMeta was missing the same level of detailed examples other functions have (and I could use the practice using Gerrit).

I started looking at go/src/regexp to try to find where to add examples and I got lost pretty quickly. Lucky for me, Francesc was around that day. He walked me through how all examples are actually in-line tests in a `example_test.go file. They follow the format of test cases followed by “Output” commented out and then the answers to the tests. For example:

func ExampleRegexp_FindString() {
re := regexp.MustCompile(“fo.?”)
fmt.Printf("%q\n", re.FindString(“seafood”))
fmt.Printf("%q\n", re.FindString(“meat”))
// Output:
// “foo”
// “”
}
Kind of cool, right?? I followed Francesc’s lead and added a function ExampleQuoteMeta and added a few I thought would be helpful. From there it’s a git change and git mail to Gerrit!

I have to say that Steve Francia challenged me to “find something that isn’t an open issue and fix it,” so I included some documentation changes for QuoteMeta in my patch. It’s going to be open for a bit longer given the additional scope, but I think it’s worth it on this one.

I can hear your question already: how did I verify it worked? Well it wasn’t easy to be honest. Running go test example_test.go -run QuoteMeta -v won’t do it since we’re working outside of our $GOPATH. I struggled to figure it out until Kale Blakenship wrote this awesome post on testing in Go. Bookmark this one for later.

You can see my completed contribution here. What I also hope you see is how simple it is to get into the flow of contributing. If you’re like me, you’ll be good at finding a small typo or missing example in the docs to start to get used to the git codereview workflow. After that, you’ll be ready to find an open issue, ideally one tagged for an upcoming release, and give it a go. No matter what you choose to do, definitely go forth and do it. The Go team proved to me just how much they care about helping us all contribute back. I can’t wait for my next git mail.

My Mentorship Experience

by Dmitri

I was looking forward to participating in the Contribution Workshop event as a mentor. I had high expectations for the event, and thought it was a great idea before it started.

I made my first contribution to Go on May 10th, 2014. I remember it was about four months from the moment I wanted to contribute, until that day, when I actually sent my first CL. It took that long to build up the courage and fully commit to figuring out the process. I was an experienced software engineer at the time. Despite that, the Go contribution process felt alien—being unlike all other processes I was already familiar with—and therefore seemed intimidating. It was well documented though, so I knew it would be just a matter of finding the time, sitting down, and doing it. The “unknown” factor kept me from giving it a shot.

After a few months passed, I thought “enough is enough,” and decided to dedicate an entire day of an upcoming weekend to figuring out the process. I set aside all of Saturday for doing one thing: sending my first CL to Go. I opened up the Contribution Guide and started following all the steps, from the very top. Within an hour, I was done. I had send my first CL. I was both in awe and shock. In awe, because I had finally sent a contribution to Go, and it was accepted! In shock, because, why did I wait so long to finally do this? Following the steps in the Contribution Guide was very easy, and the entire process went completely smoothly. If only someone had told me that I’d be done within an hour and nothing would go wrong, I would’ve done it much sooner!

Which brings me to this event and why I thought it was such a good idea. For anyone who ever wanted to contribute to Go, but felt daunted by the unfamiliar and seemingly lengthy process (like I was during those four months), this was their chance! Not only is it easy to commit to figuring it out by attending the event, but also the Go team and helpful volunteer mentors would be there to help you along the way.

Despite the already high expectations I had for the event, my expectations were exceeded. For one, the Go team had prepared really well and invested a lot in making the event that much more enjoyable for everyone. There was a very fun presentation that went over all the contributing steps quickly. There was a dashboard made for the event, where everyone’s successfully completed steps were rewarded with points towards a global score. That made it into a very collaborative and social event! Finally, and most importantly, they were Go team members like Brad Fitzpatrick behind the scenes, helping review CLs promptly! That meant the CLs that were submitted received reviews quickly, with actionable next steps, so everyone could move forward and learn more.

I originally anticipated the event to be somewhat dull, in that the contribution steps are extremely simple to follow. However, I found that wasn’t always the case, and I was able to use my expertise in Go to help out people who got stuck in various unexpected places. It turns out, the real world is filled with edge cases. For instance, someone had two git emails, one personal and another for work. There was a delay with signing the CLA for the work email, so they tried to use their personal email instead. That meant each commit had to be amended to use the right email, something the tools didn’t take into account. (Luckily, there is a troubleshooting section in the contribution guide covering this exact issue!) There were other subtle mistakes or environment misconfiguration that some people ran into, because having more than one Go installation was a bit unusual. Sometimes, the GOROOT environment variable had to be explicitly set, temporarily, to get godoc to show changes in the right standard library (I was tongue-in-cheek looking over my shoulder to check for Dave Cheney as I uttered those words).

Overall, I oversaw a few new gophers make their first Go contributions. They sent the CLs, responded to review feedback, made edits, iterated until everyone was happy, and eventually saw their first Go contributions get merged to master! It was very rewarding to see the happiness on their faces, because the joy of making one’s first contribution is something I can relate to myself. It was also great to be able to help them out, and explain tricky situations that they sometimes found themselves. From what I can tell, many happy gophers walked away from the event, myself included!

Photos from the event

Photos by Sameer Ajmani & Steve Francia

By Steve Francia, Cassandra Salisbury, Matt Broberg, Dmitri Shuralyov

See the index for more articles.

你可能感兴趣的:(go)