1. 01 Aug, 2018 9 commits
    • Russ Cox's avatar
      cmd/doc: adapt directory search for modules · b7d3f4c0
      Russ Cox authored
      Previously, cmd/doc treated GOROOT/src and GOPATH/src
      as the roots of the directory trees holding packages, assuming
      that the import path would be the path elements after the src directory.
      
      With modules, each module serves as its own root of a file tree,
      and the import path prefix starts with the module path before
      adding the path elements after the module root.
      
      There are ways we could make this more efficient,
      but for now this is a fairly small adjustment to get 'go doc'
      working OK for modules for Go 1.11.
      
      Fixes #26635.
      
      Change-Id: Ifdee4194601312846c7b1fc67f2fe7a4a44269cc
      Reviewed-on: https://go-review.googlesource.com/126799
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRob Pike <r@golang.org>
      b7d3f4c0
    • Russ Cox's avatar
      cmd/go: move module cache from $GOPATH/src/mod to $GOPATH/pkg/mod · b8f42d74
      Russ Cox authored
      Using $GOPATH/src/mod confuses too many tools.
      $GOPATH/pkg/mod seems better for now.
      It's also next to dep's cache, $GOPATH/pkg/dep.
      If we do eliminate GOPATH/pkg for holding .a files (#4719)
      then we could still keep it around for pkg/mod.
      (Or we could move the module cache again then.)
      
      Fixes #26401.
      Fixes #26635.
      
      Change-Id: I18f7da216ed9f490eded3c00d837fb086ae5b6a4
      Reviewed-on: https://go-review.googlesource.com/126755
      Run-TryBot: Russ Cox <rsc@golang.org>
      Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
      Reviewed-by: 's avatarRob Pike <r@golang.org>
      b8f42d74
    • Russ Cox's avatar
      cmd/go: add list -find to find packages but not resolve imports · 27e546be
      Russ Cox authored
      This is needed by golang.org/x/tools/go/packages
      and also gives a way to do a quicker scan for
      packages with a given final path element:
      
      	go list -find .../template
      
      Change-Id: I092f4ac5ba7af7d727eb8204379fa436667061b9
      Reviewed-on: https://go-review.googlesource.com/126716
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
      27e546be
    • Russ Cox's avatar
      cmd/go: allow list of absolute directory path · cdac6c22
      Russ Cox authored
      Relative directory paths have always worked.
      This CL makes absolute directory paths be handled the same way.
      (It was an oversight that they were excluded.)
      
      It also fixes the case of naming the directory holding source code
      for a package in a module dependency.
      
      Fixes #14177.
      Fixes #26550.
      
      Change-Id: I29a0ca2795d35eca773121ee91a97628b56947ce
      Reviewed-on: https://go-review.googlesource.com/126715
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarMichael Matloob <matloob@golang.org>
      Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
      cdac6c22
    • Russ Cox's avatar
      cmd/go: replace -getmode with -mod, $GOPROXY · 30a84b38
      Russ Cox authored
      The old -getmode flag had two settings:
      -getmode=local meant don't download from the network.
      -getmode=vendor meant only use the vendor directory.
      
      The new -mod flag has two settings:
      -mod=readonly means refuse to automatically update go.mod (mainly for CI testing).
      -mod=vendor means only use the vendor directory.
      
      The old GOPROXY variable had two settings:
      a proxy URL or else the empty string (direct connect).
      
      The new GOPROXY variable has three settings:
      a proxy URL, the string "off" (no network use allowed),
      or else the empty string or the explicit string "direct" (direct connection).
      We anticipate allow a comma-separated sequence in a future release,
      so commas are disallowed entirely right now.
      
      Fixes #24666.
      Fixes #26586.
      Fixes #26370.
      Fixes #26361.
      
      Change-Id: If2601a16b09f04800f666938c071fc053b4c3f9c
      Reviewed-on: https://go-review.googlesource.com/126696
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
      30a84b38
    • Russ Cox's avatar
      cmd/go: add $GOFLAGS environment variable · c1a4fc3b
      Russ Cox authored
      People sometimes want to turn on a particular go command flag by default.
      In Go 1.11 we have at least two different cases where users may need this.
      
      1. Linking can be noticeably slower on underpowered systems
      due to DWARF, and users may want to set -ldflags=-w by default.
      
      2. For modules, some users or CI systems will want vendoring always,
      so they want -getmode=vendor (soon to be -mod=vendor) by default.
      
      This CL generalizes the problem to “set default flags for the go command.”
      
      $GOFLAGS can be a space-separated list of flag settings, but each
      space-separated entry in the list must be a standalone flag.
      That is, you must do 'GOFLAGS=-ldflags=-w' not 'GOFLAGS=-ldflags -w'.
      The latter would mean to pass -w to go commands that understand it
      (if any do; if not, it's an error to mention it).
      
      For #26074.
      For #26318.
      Fixes #26585.
      
      Change-Id: I428f79c1fbfb9e41e54d199c68746405aed2319c
      Reviewed-on: https://go-review.googlesource.com/126656
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarRob Pike <r@golang.org>
      c1a4fc3b
    • Russ Cox's avatar
      cmd/go: change list -compiled to populate new CompiledGoFiles list · 53859e57
      Russ Cox authored
      CL 108156 added -cgo during the Go 1.11 cycle.
      To avoid adding a new field to Package, it redefined the
      meaning of the CgoFiles list to be the cgo output instead
      of the cgo input.
      
      This was awkward in the go command itself, since the meaning
      of the list changed midway through the build.
      
      But, worse, it is awkward to users of go list.
      When gathering information about a tree of packages,
      we may want the names of both the cgo inputs and the cgo outputs
      (golang.org/x/tools/go/packages does, it turns out),
      or when combined with -deps (CL 107776),
      we may only care about one list or the other depending
      on whether the package was requested explicitly or is
      being returned as a dependency.
      
      Also, it's not general enough. SWIGFiles turn into cgo files
      and then end up in the list too. And maybe there will be others
      in the future. What clients really want is the list of files that
      are presented to the go compiler, so that they can parse
      and type-check them as if they were the compiler instead.
      
      Eliminate all this awkwardness by dropping -cgo and adding
      a new -compiled that populates a new CompiledGoFiles list.
      
      Change-Id: I5f152da17cfb2692eedde61721d01ec13067c57d
      Reviewed-on: https://go-review.googlesource.com/126695
      Run-TryBot: Russ Cox <rsc@golang.org>
      Reviewed-by: 's avatarMichael Matloob <matloob@golang.org>
      Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
      53859e57
    • Russ Cox's avatar
      cmd/go: split go mod into multiple subcommands · 6121987a
      Russ Cox authored
      The current "go mod" command does too many things.
      The design is unclear.
      
      It looks like "everything you might want to do with modules"
      which causes people to think all module operations go through
      "go mod", which is the opposite of the seamless integration we're
      going for. In particular too many people think "go mod -require"
      and "go get" are the same.
      
      It does make sense to put the module-specific functionality
      under "go mod", but not as flags. Instead, split "go mod" into
      multiple subcommands:
      
      	go mod edit   # old go mod -require ...
      	go mod fix    # old go mod -fix
      	go mod graph  # old go mod -graph
      	go mod init   # old go mod -init
      	go mod tidy   # old go mod -sync
      	go mod vendor # old go mod -vendor
      	go mod verify # old go mod -verify
      
      Splitting out the individual commands makes both the docs
      and the implementations dramatically easier to read.
      It simplifies the command lines
      (go mod -init -module m is now 'go mod init m')
      and allows command-specific flags.
      
      We've avoided subcommands in the go command to date, and we
      should continue to avoid adding them unless it really makes
      the experience significantly better. In this case, it does.
      
      Creating subcommands required some changes in the core
      command-parsing and help logic to generalize from one
      level to multiple levels.
      
      As part of having "go mod init" be a separate command,
      this CL changes the failure behavior during module initialization
      to be delayed until modules are actually needed.
      Initialization can still happen early, but the base.Fatalf
      is delayed until something needs to use modules.
      This fixes a bunch of commands like 'go env' that were
      unhelpfully failing with GO111MODULE=on when not in a
      module directory.
      
      Fixes #26432.
      Fixes #26581.
      Fixes #26596.
      Fixes #26639.
      
      Change-Id: I868db0babe8c288e8af684b29d4a5ae4825d6407
      Reviewed-on: https://go-review.googlesource.com/126655
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
      6121987a
    • Russ Cox's avatar
      cmd/go: add 'go version' statement in go.mod · 16962faf
      Russ Cox authored
      We aren't planning to use this or advertise it much yet,
      but having support for it now will make it easier to start
      using in the future - older go commands will understand
      what 'go 1.20' means and that they don't have go 1.20.
      
      Fixes #23969.
      
      Change-Id: I729130b2690d3c0b794b49201526b53de5093c45
      Reviewed-on: https://go-review.googlesource.com/125940
      Run-TryBot: Russ Cox <rsc@golang.org>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
      16962faf
  2. 31 Jul, 2018 20 commits
  3. 30 Jul, 2018 3 commits
  4. 29 Jul, 2018 3 commits
  5. 28 Jul, 2018 5 commits