L
L
levisl2015-04-28 03:09:21
go
levisl, 2015-04-28 03:09:21

Why does regexp in golang truncate a string?

The essence of the question is simple - if I use regexp to search for substring a in string b, then after that, for some reason, string b is cut.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lelvisl, 2015-04-28
@lelvisl

Andrey Andrey
At night, I found out experimentally that the regexp call coincides 99% with the appearance of this problem. But not always, so that's not the problem.
And yes, I will expand the problem in more detail
. There is golang, there is a plugin, go-curl. My goal is to parse pages

package main

import (
    "fmt"
    curl "github.com/andelf/go-curl"
)

func main() {
    easy := curl.EasyInit()
    defer easy.Cleanup()

    easy.Setopt(curl.OPT_URL, "http://www.baidu.com/")

    // make a callback function
    fooTest := func (buf []byte, userdata interface{}) bool {
        println("DEBUG: size=>", len(buf))
        println("DEBUG: content=>", string(buf))
        return true
    }

    easy.Setopt(curl.OPT_WRITEFUNCTION, fooTest)

    if err := easy.Perform(); err != nil {
        fmt.Printf("ERROR: %v\n", err)
    }
}

So I want to take out the content, for this in fooTest I assign string (buf) to the global variable K (I don’t see any other way to pull out the contents of the web page for processing), and after the assignment I catch a floating error - the top of the html page is cut off

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question