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.
 
 
 

45 lines
735 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. package main
  7. import (
  8. "fmt"
  9. "log"
  10. "os"
  11. "github.com/golang/gddo/database"
  12. )
  13. var (
  14. popularCommand = &command{
  15. name: "popular",
  16. usage: "popular",
  17. }
  18. )
  19. func init() {
  20. popularCommand.run = popular
  21. }
  22. func popular(c *command) {
  23. if len(c.flag.Args()) != 0 {
  24. c.printUsage()
  25. os.Exit(1)
  26. }
  27. db, err := database.New()
  28. if err != nil {
  29. log.Fatal(err)
  30. }
  31. pkgs, err := db.PopularWithScores()
  32. if err != nil {
  33. log.Fatal(err)
  34. }
  35. for _, pkg := range pkgs {
  36. fmt.Println(pkg.Path, pkg.Synopsis)
  37. }
  38. }