Golang中url.openStream()的等效函数

时间:2015-10-24 05:18:27

标签: url go

import java.net.*;
import java.io.*;

public class URLReader {
    public static void main(String[] args) throws Exception {

    URL oracle = new URL("http://www.oracle.com/");
    BufferedReader in = new BufferedReader(
    new InputStreamReader(oracle.openStream()));

    String inputLine;
    while ((inputLine = in.readLine()) != null)
        System.out.println(inputLine);
    in.close();
}
}

我需要在golang中做同样的事情,即阅读并打印html源代码,但找不到两者之间的关系,我是Go语言的初学者,提前谢谢

1 个答案:

答案 0 :(得分:3)

希望这会有所帮助:

*

有关详情:https://golang.org/pkg/net/http/