Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: daixiang0/gci
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.12.3
Choose a base ref
...
head repository: daixiang0/gci
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.13
Choose a head ref
  • 2 commits
  • 18 files changed
  • 2 contributors

Commits on Feb 27, 2024

  1. Add basic attempt at local module handling (#179)

    The idea here is to support a new formatting section, `module`, which is
    the module we're currently running in as a replacement for
    `prefix(module/we/are/running/in)`.
    
    Since this is dependent on the directory structure and where things are
    run, some tests have been added which run on a real module structure.
    
    This approach just focusses on the use-case of running `gci` from
    the top level of a module. It does not, for example support:
    
    * Discovering modules with a nested structure
    * Discovering modules defined in a `go.work` file
    
    It was considered to get the module from `go list -m`, but this would
    drag in all modules defined under the current directory (i.e. those in
    `go.work`) which might be confusing if those modules are importing each
    other. This could be improved, if we know the name of the file whose
    imports we're processing we could check if that file is under the
    directory of a given local module (possible improvement for the future).
    
    Another alternative to consider would be using query patterns with
    `golang.org/x/tools/go/packages` e.g.
    
        config := packages.Config{Mode: packages.NeedModule | packages.NeedFiles | packages.NeedName}
        // where each "file=" maps to a file given as an argument to gci
        packages, err := packages.Load(
            &config,
            "file=./path/to/file.go",
            "file=./path/to/other.go",
        )
    
    Signed-off-by: Matthew Hughes <[email protected]>
    matthewhughes934 authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    ad52d54 View commit details
    Browse the repository at this point in the history
  2. bump up to 0.13 (#190)

    Signed-off-by: Loong <[email protected]>
    daixiang0 authored Feb 27, 2024
    Configuration menu
    Copy the full SHA
    e9e4f70 View commit details
    Browse the repository at this point in the history
Loading