这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@joohoi
Copy link
Member

@joohoi joohoi commented May 13, 2021

No description provided.

@joohoi joohoi merged commit ee0705e into master May 13, 2021
// SaveFile saves the current results to a file of a given type
func (s *Stdoutput) SaveFile(filename, format string) error {
var err error
if s.config.OutputSkipEmptyFile && len(s.Results) == 0 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The length of s.Results is not guaranteed to have the results stored in it at the time of this check. This is because they may still be sitting in s.CurrentResults having not been appended. This means when we use the -or argument it will always fail to create a file!

We need to check the length of the result from append(s.Results, s.CurrentResults...) as you were doing previously inside each writeJSON, writeEJSON...

nit: it would be simpler to have one line like:

res = append(s.Results, s.CurrentResults...)

and use the res as an arg to pass to all the output functions.

@joohoi joohoi deleted the fix_or branch February 2, 2023 13:40
joohoi added a commit that referenced this pull request Feb 3, 2023
* Fix an issue where output file was created regardless of -or

* Add CHANGELOG entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants