[整理]golang文件操作

2019-5-26 张宇童 关注网络

package main 

import(
	"fmt"
	"os"
	"io"
)

func main () {
	fp,err := os.OpenFile("1.php",os.O_RDWR,6);
	if err != nil {
		fmt.Println(err);
	}
	var a []byte;
	var b = make([]byte,10);
	for {
		n,err := fp.Read(b); 
		if err == io.EOF{
			break;
		}
		a = append(a,b[:n]...);
	}
	fmt.Println(string(a));
}

发表评论:

Powered by emlog