ray-x / go.nvim

G'day Nvimer, Joyful Gopher: Discover the Feature-Rich Go Plugin for Neovim
MIT License
1.9k stars 119 forks source link

vim shows import error until re-open #467

Open ep4sh opened 1 month ago

ep4sh commented 1 month ago

Hi, could you please tell me either this is my misconfiguration or a bug:

1) create new dir:

mkdir bla && cd bla

2) create new module:

go mod init ep4sh

3) open file main.go and add any code, which includes import section, like the following:

package main

import (
    "log"
    "time"

    env "github.com/Netflix/go-env"
)

type Environment struct {
    Home string `env:"HOME"`

    Jenkins struct {
        BuildId     *string `env:"BUILD_ID"`
        BuildNumber int     `env:"BUILD_NUMBER"`
        Ci          bool    `env:"CI"`
    }

    Node struct {
        ConfigCache *string `env:"npm_config_cache,NPM_CONFIG_CACHE"`
    }

    Extras env.EnvSet

    Duration      time.Duration `env:"TYPE_DURATION"`
    DefaultValue  string        `env:"MISSING_VAR,default=default_value"`
    RequiredValue string        `env:"IM_REQUIRED,required=true"`
}

func main() {
    var environment Environment
    es, err := env.UnmarshalFromEnviron(&environment)
    if err != nil {
        log.Fatal(err)
    }
    // Remaining environment variables.
    environment.Extras = es

    // ...

    es, err = env.Marshal(environment)
    if err != nil {
        log.Fatal(err)
    }

    home := "/tmp/edgarl"
    cs := env.ChangeSet{
        "HOME":         &home,
        "BUILD_ID":     nil,
        "BUILD_NUMBER": nil,
    }
    es.Apply(cs)

    environment = Environment{}
    err = env.Unmarshal(es, &environment)
    if err != nil {
        log.Fatal(err)
    }

    environment.Extras = es
}

4) Exec go mod tidy / go get - to download dependency. 5) See an error in nvim: image only vim re-open could remove the error

my editor: NVIM v0.10.0 Build type: Release LuaJIT 2.1.1713773202

go.nvim is latest available in Lazy (commit 588ab7b)

Thanks!

ray-x commented 1 month ago

You may need to run GoGet .

ep4sh commented 1 month ago

That helps me a lot, thank you very much! Do you consider making this action automatically? I'm not sure how does it work internally, but as user I wish to have this feature :>

Feel free to close this issue. regards, Pasha.