all: add README.md files where missing, and tool to keep them updated

Change-Id: I385171c415bf168c04c6c3a7a996bff88964af84
Reviewed-on: https://go-review.googlesource.com/52856
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Brad Fitzpatrick 2017-08-02 21:26:21 +00:00
Родитель d29668b51d
Коммит 73f88a6d4c
58 изменённых файлов: 483 добавлений и 0 удалений

7
auth/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/auth?status.svg)](https://godoc.org/golang.org/x/build/auth)
# golang.org/x/build/auth
Package auth contains shared code related to OAuth2 and obtaining tokens for a project.

7
autocertcache/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/autocertcache?status.svg)](https://godoc.org/golang.org/x/build/autocertcache)
# golang.org/x/build/autocertcache
Package autocertcache contains autocert.Cache implementations for golang.org/x/crypto/autocert.

7
buildenv/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/buildenv?status.svg)](https://godoc.org/golang.org/x/build/buildenv)
# golang.org/x/build/buildenv
Package buildenv contains definitions for the environments the Go build system can run in.

7
buildlet/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/buildlet?status.svg)](https://godoc.org/golang.org/x/build/buildlet)
# golang.org/x/build/buildlet
Package buildlet contains client tools for working with a buildlet server.

7
cmd/builder/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/builder?status.svg)](https://godoc.org/golang.org/x/build/cmd/builder)
# golang.org/x/build/cmd/builder
The builder binary is the old continuous build client for the Go project.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/buildlet/stage0?status.svg)](https://godoc.org/golang.org/x/build/cmd/buildlet/stage0)
# golang.org/x/build/cmd/buildlet/stage0
The stage0 command looks up the buildlet's URL from its environment (GCE metadata service, scaleway, etc), downloads it, and runs it.

7
cmd/buildstats/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/buildstats?status.svg)](https://godoc.org/golang.org/x/build/cmd/buildstats)
# golang.org/x/build/cmd/buildstats
The buildstats command syncs build logs from Datastore to Bigquery.

7
cmd/cl/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/cl?status.svg)](https://godoc.org/golang.org/x/build/cmd/cl)
# golang.org/x/build/cmd/cl
CL prints a list of open Go code reviews (also known as change lists, or CLs).

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/coordinator/buildongce?status.svg)](https://godoc.org/golang.org/x/build/cmd/coordinator/buildongce)
# golang.org/x/build/cmd/coordinator/buildongce

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/coordinator/metrics?status.svg)](https://godoc.org/golang.org/x/build/cmd/coordinator/metrics)
# golang.org/x/build/cmd/coordinator/metrics
Package metrics enumerates the set of Stackdriver metrics used by the Go build system.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/coordinator/spanlog?status.svg)](https://godoc.org/golang.org/x/build/cmd/coordinator/spanlog)
# golang.org/x/build/cmd/coordinator/spanlog
Package spanlog provides span and event logger interfaces that are used by the build coordinator infrastructure.

7
cmd/debugnewvm/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/debugnewvm?status.svg)](https://godoc.org/golang.org/x/build/cmd/debugnewvm)
# golang.org/x/build/cmd/debugnewvm
The debugnewvm command creates and destroys a VM-based GCE buildlet with lots of logging for debugging.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/docker2boot?status.svg)](https://godoc.org/golang.org/x/build/cmd/docker2boot)
# golang.org/x/build/cmd/docker2boot
The docker2boot command converts a Docker image into a bootable GCE VM image.

7
cmd/fetchlogs/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/fetchlogs?status.svg)](https://godoc.org/golang.org/x/build/cmd/fetchlogs)
# golang.org/x/build/cmd/fetchlogs
Fetchlogs downloads build failure logs from the Go dashboard so they can be accessed and searched from the local file system.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/genbootstrap?status.svg)](https://godoc.org/golang.org/x/build/cmd/genbootstrap)
# golang.org/x/build/cmd/genbootstrap
The genbootstrap command prepares GO_BOOTSTRAP tarballs suitable for use on builders.

7
cmd/gitlock/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/gitlock?status.svg)](https://godoc.org/golang.org/x/build/cmd/gitlock)
# golang.org/x/build/cmd/gitlock
The gitlock command helps write Dockerfiles with a bunch of lines to lock git dependencies in place.

7
cmd/gitmirror/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/gitmirror?status.svg)](https://godoc.org/golang.org/x/build/cmd/gitmirror)
# golang.org/x/build/cmd/gitmirror
The gitmirror binary watches the specified Gerrit repositories for new commits and reports them to the build dashboard.

7
cmd/gomote/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/gomote?status.svg)](https://godoc.org/golang.org/x/build/cmd/gomote)
# golang.org/x/build/cmd/gomote
The gomote command is a client for the Go builder infrastructure.

7
cmd/gopherbot/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/gopherbot?status.svg)](https://godoc.org/golang.org/x/build/cmd/gopherbot)
# golang.org/x/build/cmd/gopherbot
The gopherbot command runs Go's gopherbot role account on GitHub and Gerrit.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/gopherstats?status.svg)](https://godoc.org/golang.org/x/build/cmd/gopherstats)
# golang.org/x/build/cmd/gopherstats

7
cmd/makemac/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/makemac?status.svg)](https://godoc.org/golang.org/x/build/cmd/makemac)
# golang.org/x/build/cmd/makemac
The makemac command starts OS X VMs for the builders.

7
cmd/perfrun/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/perfrun?status.svg)](https://godoc.org/golang.org/x/build/cmd/perfrun)
# golang.org/x/build/cmd/perfrun
perfrun interacts with the buildlet coordinator to run the go1 benchmarks on a buildlet slave for the most recent successful commits according to the build dashboard.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/pubsubhelper/pubsubtypes?status.svg)](https://godoc.org/golang.org/x/build/cmd/pubsubhelper/pubsubtypes)
# golang.org/x/build/cmd/pubsubhelper/pubsubtypes
Package pubsubtypes contains types published by pubsubhelper.

7
cmd/racebuild/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/racebuild?status.svg)](https://godoc.org/golang.org/x/build/cmd/racebuild)
# golang.org/x/build/cmd/racebuild
racebuild builds the race runtime (syso files) on all supported OSes using gomote.

7
cmd/release/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/release?status.svg)](https://godoc.org/golang.org/x/build/cmd/release)
# golang.org/x/build/cmd/release
Command release builds a Go release.

7
cmd/relnote/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/relnote?status.svg)](https://godoc.org/golang.org/x/build/cmd/relnote)
# golang.org/x/build/cmd/relnote
The relnote command summarizes the Go changes in Gerrit marked with RELNOTE annotations for the release notes.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/retrybuilds?status.svg)](https://godoc.org/golang.org/x/build/cmd/retrybuilds)
# golang.org/x/build/cmd/retrybuilds
The retrybuilds command clears build failures from the build.golang.org dashboard to force them to be rebuilt.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/rundockerbuildlet?status.svg)](https://godoc.org/golang.org/x/build/cmd/rundockerbuildlet)
# golang.org/x/build/cmd/rundockerbuildlet
The rundockerbuildlet command loops forever and creates and cleans up Docker containers running reverse buildlets.

7
cmd/scaleway/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/scaleway?status.svg)](https://godoc.org/golang.org/x/build/cmd/scaleway)
# golang.org/x/build/cmd/scaleway
The scaleway command creates ARM servers on Scaleway.com.

7
cmd/upload/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/cmd/upload?status.svg)](https://godoc.org/golang.org/x/build/cmd/upload)
# golang.org/x/build/cmd/upload
The upload command writes a file to Google Cloud Storage.

7
dashboard/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/dashboard?status.svg)](https://godoc.org/golang.org/x/build/dashboard)
# golang.org/x/build/dashboard
Package dashboard contains shared configuration and logic used by various pieces of the Go continuous build system.

7
envutil/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/envutil?status.svg)](https://godoc.org/golang.org/x/build/envutil)
# golang.org/x/build/envutil
Package envutil provides utilities for working with environment variables.

7
gerrit/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/gerrit?status.svg)](https://godoc.org/golang.org/x/build/gerrit)
# golang.org/x/build/gerrit
Package gerrit contains code to interact with Gerrit servers.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/internal/buildgo?status.svg)](https://godoc.org/golang.org/x/build/internal/buildgo)
# golang.org/x/build/internal/buildgo
Package buildgo provides tools for pushing and building the Go distribution on buildlets.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/internal/gophers?status.svg)](https://godoc.org/golang.org/x/build/internal/gophers)
# golang.org/x/build/internal/gophers
Package gophers is a list of names, emails, and Github usernames of people from the Go git repos and issue trackers.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/internal/httpdl?status.svg)](https://godoc.org/golang.org/x/build/internal/httpdl)
# golang.org/x/build/internal/httpdl
Package httpdl downloads things from HTTP to local disk.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/internal/loghash?status.svg)](https://godoc.org/golang.org/x/build/internal/loghash)
# golang.org/x/build/internal/loghash
Package loghash provides the shared information for computing a log hash (as in https://build.golang.org/log/HASH).

7
internal/lru/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/internal/lru?status.svg)](https://godoc.org/golang.org/x/build/internal/lru)
# golang.org/x/build/internal/lru
Package lru implements an LRU cache.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/internal/singleflight?status.svg)](https://godoc.org/golang.org/x/build/internal/singleflight)
# golang.org/x/build/internal/singleflight
Package singleflight provides a duplicate function call suppression mechanism.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/internal/sourcecache?status.svg)](https://godoc.org/golang.org/x/build/internal/sourcecache)
# golang.org/x/build/internal/sourcecache
Package sourcecache provides a cache of code found in Git repositories.

7
internal/untar/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/internal/untar?status.svg)](https://godoc.org/golang.org/x/build/internal/untar)
# golang.org/x/build/internal/untar
Package untar untars a tarball to disk.

7
kubernetes/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/kubernetes?status.svg)](https://godoc.org/golang.org/x/build/kubernetes)
# golang.org/x/build/kubernetes
Package kubernetes contains a minimal client for the Kubernetes API.

7
kubernetes/api/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/kubernetes/api?status.svg)](https://godoc.org/golang.org/x/build/kubernetes/api)
# golang.org/x/build/kubernetes/api
Package api contains the Kubernetes v1 API types.

7
kubernetes/gke/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/kubernetes/gke?status.svg)](https://godoc.org/golang.org/x/build/kubernetes/gke)
# golang.org/x/build/kubernetes/gke
Package gke contains code for interacting with Google Container Engine (GKE), the hosted version of Kubernetes on Google Cloud Platform.

7
livelog/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/livelog?status.svg)](https://godoc.org/golang.org/x/build/livelog)
# golang.org/x/build/livelog
Package livelog provides a buffer that can be simultaneously written to by one writer and read from by many readers.

7
maintner/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/maintner?status.svg)](https://godoc.org/golang.org/x/build/maintner)
# golang.org/x/build/maintner
Package maintner mirrors, searches, syncs, and serves Git, Github, and Gerrit metadata.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/maintner/godata?status.svg)](https://godoc.org/golang.org/x/build/maintner/godata)
# golang.org/x/build/maintner/godata
Package godata loads the Go project's corpus of Git, Github, and Gerrit activity into memory to allow easy analysis without worrying about APIs and their pagination, quotas, and other nuisances and limitations.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/maintner/gostats?status.svg)](https://godoc.org/golang.org/x/build/maintner/gostats)
# golang.org/x/build/maintner/gostats
The gostats command computes stats about the Go project.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/maintner/maintnerd?status.svg)](https://godoc.org/golang.org/x/build/maintner/maintnerd)
# golang.org/x/build/maintner/maintnerd
The maintnerd command serves project maintainer data from Git, Github, and/or Gerrit.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/maintner/maintpb?status.svg)](https://godoc.org/golang.org/x/build/maintner/maintpb)
# golang.org/x/build/maintner/maintpb
Package maintpb is a generated protocol buffer package.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/maintner/maintq?status.svg)](https://godoc.org/golang.org/x/build/maintner/maintq)
# golang.org/x/build/maintner/maintq
The maintq command queries a maintnerd gRPC server.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/maintner/reclog?status.svg)](https://godoc.org/golang.org/x/build/maintner/reclog)
# golang.org/x/build/maintner/reclog
Package reclog contains readers and writers for a record wrapper format used by maintner.

Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/maintner/slurpgit?status.svg)](https://godoc.org/golang.org/x/build/maintner/slurpgit)
# golang.org/x/build/maintner/slurpgit

7
pargzip/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/pargzip?status.svg)](https://godoc.org/golang.org/x/build/pargzip)
# golang.org/x/build/pargzip
Package pargzip contains a parallel gzip writer implementation.

7
revdial/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/revdial?status.svg)](https://godoc.org/golang.org/x/build/revdial)
# golang.org/x/build/revdial
Package revdial implements a Dialer and Listener which work together to turn an accepted connection (for instance, a Hijacked HTTP request) into a Dialer which can then create net.Conns connecting back to the original dialer, which then gets a net.Listener accepting those conns.

7
tarutil/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/tarutil?status.svg)](https://godoc.org/golang.org/x/build/tarutil)
# golang.org/x/build/tarutil
Package tarutil contains utilities for working with tar archives.

7
types/README.md Normal file
Просмотреть файл

@ -0,0 +1,7 @@
<!-- Auto-generated by x/build/update-readmes.go -->
[![GoDoc](https://godoc.org/golang.org/x/build/types?status.svg)](https://godoc.org/golang.org/x/build/types)
# golang.org/x/build/types
Package types contains common types used by the Go continuous build system.

84
update-readmes.go Normal file
Просмотреть файл

@ -0,0 +1,84 @@
// 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 ignore
// The update-readmes.go tool creates or updates README.md files in
// the golang.org/x/build tree. It only updates files if they are
// missing or were previously generated by this tool.
//
// The auto-generated Markdown contains the package doc synopsis
// and a link to godoc.org for the API reference.
package main
import (
"bytes"
"fmt"
"go/build"
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
)
func main() {
root, err := build.Import("golang.org/x/build", "", build.FindOnly)
if err != nil {
log.Fatalf("failed to find golang.org/x/build root: %v", err)
}
err = filepath.Walk(root.Dir, func(path string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
if !fi.IsDir() {
return nil
}
rest := strings.TrimPrefix(strings.TrimPrefix(path, root.Dir), "/")
switch rest {
case "env", "version", "vendor":
return filepath.SkipDir
}
pkgName := "golang.org/x/build/" + filepath.ToSlash(rest)
pkg, err := build.Import(pkgName, "", 0)
if err != nil {
// Skip.
return nil
}
if _, err := os.Stat(filepath.Join(pkg.Dir, "README")); err == nil {
// Directory has exiting README; don't touch.
return nil
}
readmePath := filepath.Join(pkg.Dir, "README.md")
exist, err := ioutil.ReadFile(readmePath)
if err != nil && !os.IsNotExist(err) {
// A real error.
return err
}
const header = "Auto-generated by x/build/update-readmes.go"
if len(exist) > 0 && !bytes.Contains(exist, []byte(header)) {
return nil
}
newContents := []byte(fmt.Sprintf(`<!-- %s -->
[![GoDoc](https://godoc.org/%s?status.svg)](https://godoc.org/%s)
# %s
%s
`, header, pkgName, pkgName, pkgName, pkg.Doc))
if bytes.Equal(exist, newContents) {
return nil
}
if err := ioutil.WriteFile(readmePath, newContents, 0644); err != nil {
return err
}
log.Printf("Wrote %s", readmePath)
return nil
})
if err != nil {
log.Fatal(err)
}
}