Пример #1
0
func init() {
	dsn := DsnTcpIpV4("root", "123", "127.0.0.1", "3306", "test")

	path := "/tmp/test_mysql.log"

	w, _ := writer.NewFileWriter(path)
	logger, _ := log.NewSimpleLogger(w, log.LEVEL_INFO, new(log.SimpleFormater))

	dao, _ = NewDao(dsn, logger)
}
Пример #2
0
Файл: main.go Проект: Andals/gpm
func main() {
	if flag.NArg() < 1 {
		fmt.Println("Usage: andals-gpm install")
		return
	}

	cmd, err := commands.GetCommand(flag.Arg(0))
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	writer, _ := logWriter.NewFileWriter("/dev/stdout")
	logger, _ := log.NewSimpleLogger(writer, conf.GetLogLevel())

	prjHome, _ := os.Getwd()
	cmd.Run(prjHome, logger)
}
Пример #3
0
func TestClientGet(t *testing.T) {
	path := "/tmp/test_http_client.log"
	w, _ := logWriter.NewFileWriter(path)
	logger, _ := log.NewSimpleLogger(w, log.LEVEL_INFO)

	client := NewClient(logger).SetTimeout(time.Second * 3).SetMaxIdleConnsPerHost(10)
	extHeaders := map[string]string{
		"GO-CLIENT-1": "gobox-httpclient-1",
		"GO-CLIENT-2": "gobox-httpclient-2",
	}
	req, _ := NewRequestForGet("http://www.vdocker.com/test.php", "127.0.0.1", extHeaders)

	resp, err := client.Do(req, 1)
	fmt.Println(string(resp.Contents), resp.T.String(), err)

	req, _ = NewRequestForGet("http://www.vdocker.com/index.html", "127.0.0.1", extHeaders)

	resp, err = client.Do(req, 1)
	fmt.Println(string(resp.Contents), resp.T.String(), err)
}