Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use literal newline in order to properly split the string#3358

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sbatial wants to merge1 commit intofatih:master
base:master
Choose a base branch
Loading
fromsbatial:unix-formatting-string

Conversation

@sbatial
Copy link

@sbatialsbatial commentedFeb 16, 2022
edited
Loading

This should fixgo#tool#Files() andgo#tool#Imports() as described by my comment in#3300.

All tests passed. 👍 🚀

@sbatialsbatial marked this pull request as ready for reviewFebruary 16, 2022 16:30
@bhcleek
Copy link
Collaborator

I'm not sure that this solves the problem or that it doesn't introduce a new one on some OSes.

In any case, I can't duplicate#3300 at all, and I don't see any reason that the current form would be a problem.

Can you duplicate the problem described in#3300 with Vim or only with Neovim?

@bhcleek
Copy link
Collaborator

I'd also be interested in knowing what you see for thesego list commands on master wheng:go_debug is set to['shell-commands'] (e.g.let g:go_debug=['shell-commands'] in your vimrc).

@bhcleek
Copy link
Collaborator

FWIW, Ican duplicate the issue with Neovim, but not with Vim. It seems like the issue here may be how Neovim is handling escaped characters when it invokes external commands.

@sbatial
Copy link
Author

Ah that's interesting.
I thought this was a Windows/Linux thing. I actually didn't try it with Vim.

I'll try it with Vim, but if you can only reproduce it with Neovim it is probably a nvim issue.

I will also look intogo list.

Yes, it seems as if it has to do with the escaping in neovim.

@sbatial
Copy link
Author

Ok, so.

I looked into it and I get the same error with vim as well (I am on master. The complete config file I load for vim as well as nvim is

let data_dir='~/.vim'ifempty(glob(data_dir .'/autoload/plug.vim'))silentexecute'!curl -fLo'.data_dir.'/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'autocmdVimEnter* PlugInstall--sync |source$MYVIMRCendifcallplug#begin(data_dir .'/plugged')Plug'fatih/vim-go', {'for':'go','do':':GoUpdateBinaries' }callplug#end()letg:go_debug=['shell-commands']

I dug around quite some time and thought I could pin it down but I couldn't settle on a definitive result.

Some findings:

  • when usingsplit(l:out, '\\n') the newline character is properly cut off
  • when running the command logged by setting the go_debug variable:
    go list -f '{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{end}}{{printf "\\n"}}{{range $f := .CgoFiles}}{{$.Dir}}/{{$f}}{{printf "\\n"}}{{end}}'
    manually in a shell I get the same result, but when usingprintf "\n" (in sh) instead it works fine

But regarding your concerns it could break compatibility on other OS: My fix uses basically the same code as ingo#util#Deps which works just fine. Given that this works I wouldn't expect any problems in the other functions.

Unfortunately I can't test it on any non-Linux OS right now to see how it behaves there.

@bhcleek
Copy link
Collaborator

when running the command logged by setting the go_debug variable:
go list -f '{{range $f := .GoFiles}}{{$.Dir}}/{{$f}}{{end}}{{printf "\\n"}}{{range $f := .CgoFiles}}{{$.Dir}}/{{$f}}{{printf "\\n"}}{{end}}'
manually in a shell I get the same result, but when usingprintf "\n" (in sh) instead it works fine

My first inclination was that what you're seeing logged is escaped for logging purposes, so it makes sense that you'd see\\n instead of\n there. But I tested that hypothesis, and I don't see\\n in the output, I only see\n. I think that may point us to the root cause for this behavior.

I wonder if the behavior you're seeing has something to do with the shell options that vim-go sets (or that itdoesn't set!)?

In a go file, what does:set output for you?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@sbatial@bhcleek

[8]ページ先頭

©2009-2025 Movatter.jp