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

  • SEARCH
  • Home
  • 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 8340017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:03:06+00:00 2026-06-09T05:03:06+00:00

I’m currently learning how to develop with Go (or golang) and I have a

  • 0

I’m currently learning how to develop with Go (or golang) and I have a strange issue:

I try to create a script looking inside an HTML file in order to get all the sources of each tags.
The goal of the script is to merge all the retrieved files.

So, that’s for the story: for now, I’m able to get the content of each JavaScript files but… I can’t concatenate them…

You can see below my script:

//Open main file
mainFilePath := "/path/to/my/file.html"
mainFileDir := path.Dir(mainFilePath)+"/"

mainFileContent, err := ioutil.ReadFile(mainFilePath)

if err == nil {
    mainFileContent := string(mainFileContent)
    var finalFileContent bytes.Buffer

    //Start RegExp searching for JavaScript src
    scriptReg, _ := regexp.Compile("<script src=\"(.*)\">")
    scripts := scriptReg.FindAllStringSubmatch(mainFileContent,-1)

    //For each SRC found...
    for _, path := range scripts {
        //We open the corresponding file
        subFileContent, err := ioutil.ReadFile(mainFileDir+path[1])

        if err == nil {
            //And we add its content to the "final" variable
            fmt.Println(finalFileContent.Write(subFileContent))
        } else {
            fmt.Println(err)
        }
    }

    //Try to display the final result
    // fmt.Println(finalFileContent.String())
    fmt.Printf(">>> %#v", finalFileContent)
    fmt.Println("Y U NO WORKS? :'(")

} else {
    fmt.Println(err)
}

So, each fmt.Println(finalFileContent.Write(subFileContent)) display something like 6161 , so I assume the Write() method is correctly executed.

But fmt.Printf(">>> %#v", finalFileContent) displays nothing. Absolutely nothing (even the “>>>” are not displayed!) And it’s the same for the commented line just above.

The funny part is that the string “Y U NO WORK ? :'(“ is correctly displayed…

Do you know why?
And do you know how to solve this issue?

Thanks in advance!

  • 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-06-09T05:03:08+00:00Added an answer on June 9, 2026 at 5:03 am

    You are ignoring some errors. What are your results when you run the following version of your code?

    package main
    
    import (
        "bytes"
        "fmt"
        "io/ioutil"
        "path"
        "regexp"
    )
    
    func main() {
        //Open main file
        mainFilePath := "/path/to/my/file.html"
        mainFileDir := path.Dir(mainFilePath) + "/"
    
        mainFileContent, err := ioutil.ReadFile(mainFilePath)
    
        if err == nil {
            mainFileContent := string(mainFileContent)
            var finalFileContent bytes.Buffer
    
            //Start RegExp searching for JavaScript src
            scriptReg, _ := regexp.Compile("<script src=\"(.*)\">")
            scripts := scriptReg.FindAllStringSubmatch(mainFileContent, -1)
    
            //For each SRC found...
            for _, path := range scripts {
                //We open the corresponding file
                subFileContent, err := ioutil.ReadFile(mainFileDir + path[1])
    
                if err == nil {
                    //And we add its content to the "final" variable
    
                    // fmt.Println(finalFileContent.Write(subFileContent))
                    n, err := finalFileContent.Write(subFileContent)
                    fmt.Println("finalFileContent Write:", n, err)
    
                } else {
                    fmt.Println(err)
                }
            }
    
            //Try to display the final result
            // fmt.Println(finalFileContent.String())
    
            // fmt.Printf(">>> %#v", finalFileContent)
            n, err := fmt.Printf(">>> %#v", finalFileContent)
            fmt.Println()
            fmt.Println("finalFileContent Printf:", n, err)
    
            fmt.Println("Y U NO WORKS? :'(")
    
        } else {
            fmt.Println(err)
        }
    }
    

    UPDATE:

    The statement:

    fmt.Println("finalFileContent Printf:", n, err)
    

    Outputs:

    finalFileContent Printf: 0 write /dev/stdout: winapi error #8
    

    or

    finalFileContent Printf: 0 write /dev/stdout: Not enough storage is available to process this command.
    

    From MSDN:

    ERROR_NOT_ENOUGH_MEMORY

    8 (0x8)

    Not enough storage is available to process this command.

    The formatted output to the Windows console overflows the buffer (circa 64KB).

    There is a related Go open issue:

    Issue 3376: windows: detect + handle console in os.File.Write

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
Basically, what I'm trying to create is a page of div tags, each has

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.