gofireflyio / aiac

Artificial Intelligence Infrastructure-as-Code Generator.
Apache License 2.0
3.52k stars 276 forks source link

fix: fprintf error #20

Closed binc4t closed 1 year ago

binc4t commented 1 year ago

Thanks for your great work! It's very useful for developers like me. However I noticed a print error. It's not hard to fix, hope this pull request would be helpful

description

change Fprintfto Fprint

How Has This Been Tested?

The second parameter of fmt.Fprintf is 'format', therefore when there are something like "%s" in code, the print would be "%!s(MISSING)", just as shown below

func Fprintf(w io.Writer, format string, a ...any) (n int, err error) {
    p := newPrinter()
    p.doPrintf(format, a)
    n, err = w.Write(p.buf)
    p.free()
    return
}
image

fmt.Fprint doesn't have parameter 'format', so the print will always be correct

func Fprint(w io.Writer, a ...any) (n int, err error) {
    p := newPrinter()
    p.doPrint(a)
    n, err = w.Write(p.buf)
    p.free()
    return
}
image
ghost commented 1 year ago
👇 Click on the image for a new way to code review - Make big changes easier — review code in small groups of related files - Know where to start — see the whole change at a glance - Take a code tour — explore the change with an interactive tour - Make comments and review — all fully sync’ed with github [Try it now!](https://app.codesee.io/r/reviews?pr=20&src=https%3A%2F%2Fgithub.com%2Fgofireflyio%2Faiac)

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

ido50 commented 1 year ago

Hi @anccy. Thank you for the PR, and sorry for taking long in responding. This PR is no longer valid and the original bug it is describing had already been fixed. Closing. Thanks again.