You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
975 B

  1. // Copyright 2013 The Go Authors. All rights reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style
  4. // license that can be found in the LICENSE file or at
  5. // https://developers.google.com/open-source/licenses/bsd.
  6. // +build ignore
  7. // Command print fetches and prints package documentation.
  8. //
  9. // Usage: go run print.go importPath
  10. package main
  11. import (
  12. "flag"
  13. "log"
  14. "net/http"
  15. "os"
  16. "github.com/davecgh/go-spew/spew"
  17. "github.com/golang/gddo/doc"
  18. "github.com/golang/gddo/gosrc"
  19. )
  20. var (
  21. etag = flag.String("etag", "", "Etag")
  22. local = flag.Bool("local", false, "Get package from local directory.")
  23. )
  24. func main() {
  25. flag.Parse()
  26. if len(flag.Args()) != 1 {
  27. log.Fatal("Usage: go run print.go importPath")
  28. }
  29. path := flag.Args()[0]
  30. var (
  31. pdoc *doc.Package
  32. err error
  33. )
  34. if *local {
  35. gosrc.SetLocalDevMode(os.Getenv("GOPATH"))
  36. }
  37. pdoc, err = doc.Get(http.DefaultClient, path, *etag)
  38. //}
  39. if err != nil {
  40. log.Fatal(err)
  41. }
  42. spew.Dump(pdoc)
  43. }