Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: import paths #29938

Closed
javapro108 opened this issue Jan 25, 2019 · 3 comments
Closed

proposal: import paths #29938

javapro108 opened this issue Jan 25, 2019 · 3 comments

Comments

@javapro108
Copy link

Please excuse me if this has already been ruled out of design.

Proposal is to:

  1. Have protocal included in import path like URL and consider paths local if import is not URL
    • Packages/modules referenced using URLs can be downloaded to local repository instead of being part of src folder.
  2. Allow path to refer to compiled modules, like packages do.

Before

package main

import (
  log "github.com/sirupsen/logrus"  
)

func main() {
......
}

After

package main

import (
  log "https://github.com/sirupsen/logrus"
  local_relative "../dir/packageone"
  local_absolute "C:/mygodir/packagetwo"
)

func main() {
......
}

@gopherbot gopherbot added this to the Proposal milestone Jan 25, 2019
@kardianos
Copy link
Contributor

@javapro108 Yes, this goes against explicit design.

You can get the effect of an absolute path by using the Go module "replace" directive. Specifying the protocol also wouldn't play nicely with modules. Modules are uniquely identified by a URL, but may be fetched from local cache, a proxy, or something else. Specifying a protocol would be counter productive.

@bcmills
Copy link
Contributor

bcmills commented Jan 25, 2019

As @kardianos notes, you can use replace directives in the go.mod file today to map module paths to specific filesystem locations. See https://tip.golang.org/cmd/go/#hdr-The_go_mod_file.

As for “compiled modules”, we are moving in exactly the opposite direction: support for binary-only packages is going away as of Go 1.13 (#28152).

Sorry, but this proposal is not in alignment with the direction we are headed with modules.

@bcmills bcmills closed this as completed Jan 25, 2019
@javapro108
Copy link
Author

Thanks for the comments @kardianos and @bcmills .

Replace seems like solution for local modules but it makes interpretation of import more complicated. On the otherhand complete URL convention does provide flexibility use standard online version and current convention can be used for local copies of the same repo which can be mofied by user.

Its sad to know Go is moving away for compiled library distributions, which can have many corporate/enterprise use cases as well as IP and security concerns.

@golang golang locked and limited conversation to collaborators Jan 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants