FAQ

It is almost certainly a mistake to extend gofmt to do more sophisticated
program rewrites. Write separate tools.

Russ
Or extract the rewriting out of gofmt into a standard library package that
can be used to write such tools?

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Andrew Gerrand at Sep 2, 2014 at 10:31 pm

    On 3 September 2014 05:45, Donovan Hide wrote:

    Or extract the rewriting out of gofmt into a standard library package that
    can be used to write such tools?

    It's definitely worth moving useful pieces into a library. Not necessarily
    for the standard library, though.

    Andrew

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rob Pike at Sep 2, 2014 at 10:47 pm
    I don't think the -r stuff belongs in gofmt. It's only there for
    historical reasons. It's so easy to build a parse tree, rewrite it,
    and format it that a proper rewriting tool would be easy to separate
    out.

    -rob

    On Tue, Sep 2, 2014 at 3:30 PM, Andrew Gerrand wrote:
    On 3 September 2014 05:45, Donovan Hide wrote:

    Or extract the rewriting out of gofmt into a standard library package that
    can be used to write such tools?

    It's definitely worth moving useful pieces into a library. Not necessarily
    for the standard library, though.

    Andrew

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Donovan Hide at Sep 3, 2014 at 1:21 am

    I don't think the -r stuff belongs in gofmt. It's only there for
    historical reasons. It's so easy to build a parse tree, rewrite it,
    and format it that a proper rewriting tool would be easy to separate
    out.
    Sounds like a great idea for a golang.org blog post! Code parsing and
    generation. The btree code seems like a great example to me. I've managed
    to get great speed ups and memory savings by converting the []Item slice
    into a slice of each concrete type I'm using, but it has involved changing
    a lot of the code manually to work well with gofmt. I've ended up using a
    TYPE and PTR substitution. I'm certain a true gopher could have done a much
    nicer and logical job!

    https://github.com/google/btree

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Andrew Gerrand at Sep 3, 2014 at 1:29 am
    A contributor wrote this talk recently:
       http://talks.golang.org/2014/hammers.slide#1

    On 3 September 2014 11:21, Donovan Hide wrote:

    I don't think the -r stuff belongs in gofmt. It's only there for
    historical reasons. It's so easy to build a parse tree, rewrite it,
    and format it that a proper rewriting tool would be easy to separate
    out.
    Sounds like a great idea for a golang.org blog post! Code parsing and
    generation. The btree code seems like a great example to me. I've managed
    to get great speed ups and memory savings by converting the []Item slice
    into a slice of each concrete type I'm using, but it has involved changing
    a lot of the code manually to work well with gofmt. I've ended up using a
    TYPE and PTR substitution. I'm certain a true gopher could have done a much
    nicer and logical job!

    https://github.com/google/btree
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 2, '14 at 7:45p
activeSep 3, '14 at 1:29a
posts5
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase