Open tehsphinx opened 4 years ago
Upstream issue: golang/go#26325
@mhutter Thanks a lot for finding the correct issues in the Go repo!
@junedev - is this something we still want to do?
Imo not a very high priority but in general yes. There is no solution of the uptream issue in sight so the problem described here still exists.
I am pondering some edge cases of the replacement logic mentioned above.
print
would also be included in fmt.Sprintf
which we don't want to change, even print(
is also part of fmt.Sprint
so to do this correctly we would also need something like "no character before the print(
as condition as wellfmt.Printf("%s)", x)
correctly, we would need to know which bracket is the closing bracket of the function call which is hard to tell, maybe we could try to find the string after the opening bracket and add a line break there instead of replacing the whole expressionThis seems to be fixed with go 1.20 for --short --json
. Still a problem with -v --json
.
The commands
print
,fmt.Print
,fmt.Printf
and maybe others currently destroy the output ofgo test --json
as they have no final newline.We should report that to be fixed in
go test
but for the time being we will replace these commands in students solutions withprintln
/fmt.Println
.My current suggestion would be to add some
sed
commands to the test runner before executing the tests. This could also be done using the AST library to manipulate the AST if someone wants to dig into that.Here the replace table I'd recommend to avoid having to remove/add imports:
print
->println
fmt.Print
->fmt.Println
fmt.Printf(...)
->fmt.Println(fmt.Sprintf(...))