Explorar o código

测试更新-1

abiao %!s(int64=3) %!d(string=hai) anos
pai
achega
6bdbdade0d

+ 0 - 37
go/gopath/src/fohow.com/tests/default_test.go

@@ -1,37 +0,0 @@
-package test
-
-import (
-	_ "api.com/routers"
-	"net/http"
-	"net/http/httptest"
-	"path/filepath"
-	"runtime"
-	"testing"
-
-	"github.com/astaxie/beego"
-	"github.com/smartystreets/goconvey/convey"
-)
-
-func init() {
-	_, file, _, _ := runtime.Caller(1)
-	apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
-	beego.TestBeegoInit(apppath)
-}
-
-// TestMain is a sample to run an endpoint test
-func TestMain(t *testing.T) {
-	r, _ := http.NewRequest("GET", "/", nil)
-	w := httptest.NewRecorder()
-	beego.BeeApp.Handlers.ServeHTTP(w, r)
-
-	beego.Trace("testing", "TestMain", "Code[%d]\n%s", w.Code, w.Body.String())
-
-	Convey("Subject: Test Station Endpoint\n", t, func() {
-		Convey("Status Code Should Be 200", func() {
-			So(w.Code, ShouldEqual, 200)
-		})
-		Convey("The Result Should Not Be Empty", func() {
-			So(w.Body.Len(), ShouldBeGreaterThan, 0)
-		})
-	})
-}

+ 39 - 0
go/gopath/src/fohow.com/tests/main.go

@@ -0,0 +1,39 @@
+package main
+
+import "fmt"
+
+func main() {
+	type SessionKey struct {
+		Openid     string `json:"openid"`      //用户唯一标识
+		SessionKey string `json:"session_key"` //会话密钥
+		Unionid    string `json:"unionid"`     //用户在开放平台的唯一标识符。本字段在满足一定条件的情况下才返回。
+	}
+	var key *SessionKey
+
+	var s1 SessionKey
+
+	s1.Openid = "123"
+
+	key = &s1
+
+	fmt.Printf("%v\n", key)
+
+	//
+
+	/**
+	*	go 语言指针区别,指针是内存地址,指向某个值,没有运算
+	* 	& 是取址操作
+	*	 * ,& 互补操作
+	 */
+	a := 10 //此时有一块内存存放了10,它的地址由系统自动分配,别名是a
+	a = 20  //内存存放的10变成了20
+
+	var p *int
+
+	fmt.Println(p)
+
+	p = &a //或者直接写 p := &a
+
+	fmt.Println(p)
+	fmt.Println(*p)
+}

+ 39 - 0
go/gopath/src/fohow.com/tests/main.test.go

@@ -0,0 +1,39 @@
+package main
+
+import "fmt"
+
+func main() {
+	type SessionKey struct {
+		Openid     string `json:"openid"`      //用户唯一标识
+		SessionKey string `json:"session_key"` //会话密钥
+		Unionid    string `json:"unionid"`     //用户在开放平台的唯一标识符。本字段在满足一定条件的情况下才返回。
+	}
+	var key *SessionKey
+
+	var s1 SessionKey
+
+	s1.Openid = "123"
+
+	key = &s1
+
+	fmt.Printf("%v\n", key)
+
+	//
+
+	/**
+	*	go 语言指针区别,指针是内存地址,指向某个值,没有运算
+	* 	& 是取址操作
+	*	 * ,& 互补操作
+	 */
+	a := 10 //此时有一块内存存放了10,它的地址由系统自动分配,别名是a
+	a = 20  //内存存放的10变成了20
+
+	var p *int
+
+	fmt.Println(p)
+
+	p = &a //或者直接写 p := &a
+
+	fmt.Println(p)
+	fmt.Println(*p)
+}