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

vim shows import error until re-open #467

Open
ep4sh opened this issue May 29, 2024 · 2 comments
Open

vim shows import error until re-open #467

ep4sh opened this issue May 29, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@ep4sh
Copy link

ep4sh commented May 29, 2024

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

  1. create new dir:
mkdir bla && cd bla
  1. create new module:
go mod init ep4sh
  1. 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
}

  1. Exec go mod tidy / go get - to download dependency.
  2. 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
Copy link
Owner

ray-x commented May 29, 2024

You may need to run GoGet .

@ep4sh
Copy link
Author

ep4sh commented Jun 2, 2024

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.

@ray-x ray-x added the enhancement New feature or request label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants