Hi all, I solved this problem by switching from go/ast to https://github.com/dave/dst. I still think something like this belongs in the stdlib.e
On Friday, November 10, 2023 at 11:09:02 PM UTC-5 Amir Omidi (aaomidi) wrote: > Hi all, > > Background is that I've been trying to tackle the issue here: > https://github.com/zmap/zlint/issues/765 > > Effectively, there is a code signature change where I want do a large > scale code change using AST to make old code conform to a new signature. > > I have the majority of this working, and it's been successfully modifying > the files. However, I've been struggling with getting the formatting > looking right. > > My code is on: > https://gist.github.com/aaomidi/1530e5fa83470598aa997227feabbe0d > > The output goes from: > > ``` > func init() { > lint.RegisterLint(&lint.Lint{ > Name: "e_rsa_fermat_factorization", > Description: "RSA key pairs that are too close to each other are > susceptible to the Fermat Factorization " + > "Method (for more information please see > https://en.wikipedia.org/wiki/Fermat%27s_factorization_method " + > "and https://fermatattack.secvuln.info/)", > Citation: "Pierre de Fermat", > Source: lint.Community, > EffectiveDate: util.ZeroDate, > Lint: NewFermatFactorization, > }) > } > ``` > to: > > ``` > func init() { > lint.RegisterCertificateLint(&lint.CertificateLint{LintMetadata: > lint.LintMetadata{Name: "e_rsa_fermat_factorization", > Description: "RSA key pairs that are too close to each other are > susceptible to the Fermat Factorization " + > "Method (for more information please see > https://en.wikipedia.org/wiki/Fermat%27s_factorization_method " + > "and https://fermatattack.secvuln.info/)", > Citation: "Pierre de Fermat", > Source: lint.Community, > EffectiveDate: util.ZeroDate}, Lint: NewFermatFactorization}) > > } > ``` > That output is not how people are used to seeing structs, how should I get > it to be formatted correctly? > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/3c8e8acd-8b94-4c6a-9e2b-af815f0d2002n%40googlegroups.com.