Why not add pattern to the output files?
Like pattern
random /tmp/nvimVaVjop/1.py /^import random$/;" i line:16
in python tags file.
Currently, i have a gotags file with line
EnvEnableProfiling /tmp/nvimORpwWJ/1.go 45;" c access:public line:45.
Normally this works with tagbar, but not this file https://github.com/ipfs/go-ipfs/blob/master/cmd/ipfs/main.go#L567, the special character '^C' break things. Tagbar#JumpToTag always go to this line for whatever tags, this is because of the empty pattern, check https://github.com/majutsushi/tagbar/blob/master/autoload/tagbar.vim#L2483.
This is likely a bug in Tagbar (see #32). Jumping works correctly if you remove the ^ character and in both cases the gotags output is the same.
I think we should not simply push this problem to tagbar, because the consequences are not only from it. First, it's because gotags doesn't output standard pattern info to tags file, as a result tagbar can't go to the right line. And the reason tagbar can't go to right line is, tagbar always first jump to the line number of a tag specified in tags file, and then check whether the pattern is located at it, for gotags case there is no pattern, so tagbar think the file has been changed after tags file are generated, and try to search pattern to locate the real location, and also because pattern is empty, tagbar can not find the right line. I think what tagbar is doing is necessary, it's better for gotags to give pattern in the tags file, if gotags can't or have trouble to give the tag pattern, maybe we can do some hack in tagbar and hide this problem.
Normally where there is a pattern in the tags file, gotags give a line number, this is useless. Tagbar can use this pattern to search for the current tag line if code are changed after tags file is generated.
This is a bit of a grey area. Technically what gotags does here is legal, as the tags file format only says that the tagaddress field should be a valid Ex command, which a simple line number is. Tagbar has so far assumed that the address is always a pattern, since it calls Ctags with the --excmd=pattern option and all the other ctags-compatible parsers I'm aware of also output a pattern.
So it's technically a bug that Tagbar doesn't properly handle line numbers (or any other kind of command) for that field, and I should fix that. On the other hand it would be very useful if gotags did output a pattern instead of a line number, mostly to make finding the tag after unsaved changes possible just as @apporc mentioned, and for the preview window functionality. The line number is already present in an extension field so doesn't add any information there.
I've fixed Tagbar so it doesn't fail if the tagaddress field is not a pattern, so normal jumping should work now. It would still be good if gotags actually output a pattern for the reasons mentioned in my previous comment.
Thanks @majutsushi for the update and fixing Tagbar! I originally used the ctags spec when creating gotags and back then outputting line numbers was the easiest thing to do. It does makes sense to output a pattern, but that would require significant code changes. I'll keep this issue open.