Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6341759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:06:07+00:00 2026-05-24T20:06:07+00:00

str := new(bytes.Buffer) //old code printer.Fprint(str, c) //old code str := new(token.FileSet) //new code

  • 0
str := new(bytes.Buffer) //old code
printer.Fprint(str, c)   //old code 
str := new(token.FileSet) //new code
printer.Fprint(os.Stdout, str, c) //new code    

source += "\t" + str.String() + ";\n"   

In this code i try to change str’s value from new(bytes.Buffer) to new(token.FileSet) because Fprint’s argument requier;
func Fprint(output io.Writer, fset *token.FileSet, node interface{}) os.Error //latest ver.
now, i’m stucking in error str.String() because str don’t have method String().
I cann’t update my code for run in latest version of Go because a changed of printer.Fprint()
How to volve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T20:06:07+00:00Added an answer on May 24, 2026 at 8:06 pm

    Here’s a sample program.

    package main
    
    import (
        "bytes"
        "fmt"
        "go/parser"
        "go/printer"
        "go/token"
    )
    
    func main() {
        const src = `package main
        func main() {}
        `
    
        fset := token.NewFileSet()
        ast, err := parser.ParseFile(fset, "", src, parser.ParseComments)
        if err != nil {
            panic(err)
        }
    
        var buf bytes.Buffer
        printer.Fprint(&buf, fset, ast)
    
        fmt.Print(buf.String())
    }
    

    Output:

    package main
    
    func main() {}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on C#, trying below code byte[] buffer = new byte[str.Length]; buffer
How can I implement the below code (ActionScript) in Python? var bytes:ByteArray = new
I'm trying to serialize/deserialize string. Using the code: private byte[] StrToBytes(string str) { BinaryFormatter
On C# side, I have this code to send unicode String byte[] b =
I have a 2 dimensional array, like so: char[,] str = new char[2,50]; Now,
string str = one three; string::iterator it; string add = two ; Lets say
When compiling this: char *str = [[NSString stringWithFormat:@%i days and %i hours, days, hours]
static void Main() { string str; str = Console.ReadLine(); while (str != null)//HERE! {
Java has a convenient split method: String str = The quick brown fox; String[]
public class MyClass { int i = 0; string str = here; MyStruct mystruct;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.