FAQ
Hii,
         I have been searching for a predefined function that would help to
read an AST and write back the source code of it to a file, is there any
function that would help me else can any one help me how to build the
source code back from an AST into a file..

I am able to modify an AST and print the source code of modified tree on
console using this //printer.Fprint(os.Stdout, fset, f)...but I want the
source code to be written back to file..can any one help me with this??

--
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/groups/opt_out.

Search Discussions

  • Ian Lance Taylor at Sep 27, 2013 at 8:03 pm

    On Fri, Sep 27, 2013 at 11:59 AM, venkatesh reddy wrote:
    Hii,
    I have been searching for a predefined function that would help to
    read an AST and write back the source code of it to a file, is there any
    function that would help me else can any one help me how to build the
    source code back from an AST into a file..

    I am able to modify an AST and print the source code of modified tree on
    console using this //printer.Fprint(os.Stdout, fset, f)...but I want the
    source code to be written back to file..can any one help me with this??
    I may not understand the question. If print.FPrint(os.Stdout, ...)
    works, then you should be able to simply do

         f, err := os.Create("out.go")
         if err != nil {
             ...
         }
         print.Fprint(f, ...)

    Ian

    --
    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/groups/opt_out.
  • Venkatesh reddy at Sep 27, 2013 at 9:37 pm
    Im sorry couldnt explain my question clearly in last post..
    Actually, what I need is to modify an AST by deleting some nodes and use
    it as parameter in my print.Fprint to write the modified source code back
    to a file..
    could you please tell me how to delte a node in AST ?
    On Friday, 27 September 2013 13:03:53 UTC-7, Ian Lance Taylor wrote:

    On Fri, Sep 27, 2013 at 11:59 AM, venkatesh reddy
    <venkateshre...@gmail.com <javascript:>> wrote:
    Hii,
    I have been searching for a predefined function that would help to
    read an AST and write back the source code of it to a file, is there any
    function that would help me else can any one help me how to build the
    source code back from an AST into a file..

    I am able to modify an AST and print the source code of modified tree on
    console using this //printer.Fprint(os.Stdout, fset, f)...but I want the
    source code to be written back to file..can any one help me with this??
    I may not understand the question. If print.FPrint(os.Stdout, ...)
    works, then you should be able to simply do

    f, err := os.Create("out.go")
    if err != nil {
    ...
    }
    print.Fprint(f, ...)

    Ian
    --
    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/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 27, '13 at 7:58p
activeSep 27, '13 at 9:37p
posts3
users2
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase