Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoweiguo committed Aug 28, 2022
1 parent e43897b commit bc20062
Show file tree
Hide file tree
Showing 57 changed files with 791 additions and 225 deletions.
21 changes: 21 additions & 0 deletions assets/cert/server.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDizCCAnMCCQD8nJ7qB1LAwTANBgkqhkiG9w0BAQsFADBxMQswCQYDVQQGEwJD
TjELMAkGA1UECAwCQkoxCzAJBgNVBAcMAkJKMQwwCgYDVQQKDANDT00xDDAKBgNV
BAsMA05TUDELMAkGA1UEAwwCQ0ExHzAdBgkqhkiG9w0BCQEWEHlvdXJlbWFpbEBx
cS5jb20wHhcNMjIwMjA3MTI0MTMzWhcNMjMwMjA3MTI0MTMzWjCBnTELMAkGA1UE
BhMCQ04xEDAOBgNVBAgMB0JlaWppbmcxEDAOBgNVBAcMB0JlaWppbmcxIDAeBgNV
BAoMF1dlaTY0IChCZWlqaW5nKSBMaW1pdGVkMQwwCgYDVQQLDANDRUQxGTAXBgNV
BAMMECouemhhb3dlaWd1by5jb20xHzAdBgkqhkiG9w0BCQEWEHlvdXJlbWFpbEBx
cS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDue2hNvi5tkGC7
0YuUpK3sbYUz8HxsbvmUX706d+aRQdgSuH9bzWW5XtzWn/8SgtRxWTnYeaGqf6zp
xrX5NQXpW01so/nunsj8dbTbhiHin2yJZ20BM3Xi2IhnV+X7CubTjGBvi6mqdHZM
Tjkemj+cqP1mD9GUK66Ny7ksmjkZ31nlD6ddaKkdv8TtkMeUgEFdVsScmt/eSxSq
whjwTHYfB+LMXdjwZxJWFevVhsUuqz41eRAFOB2ZX5A0da9HsEuX9lG17dDKBoKI
ik3UX9nggqVArW7Hme2r9egEjiWlJxGEekAWJwxZx5JUlkPddA0K71n9twcqcp8N
WoXbdoJ1AgMBAAEwDQYJKoZIhvcNAQELBQADggEBAGVAq7IvZteE2WeF2KpaImqW
CtYC3PcSgD84Pbh7Phvkl0iY5vFJvsdS5boLr89+RW9zrSoS4PkEa3vBscAwcdZg
vzg9hOviceHvN8V7mCsd2VLuL9dvNVc+tt2PQtrDyN12L9uFJMZtl8wf9s8Zz2E1
l40iKa0zF6yPcwxP0ERt8vQKtUq5TsdQHgy7L6ajwVgBy9MTUAzo7zceEUaPfzV9
kvBMYBoDCrkJc1qbXDeuX9qvG+SJ1+nPkAiksvM79O/kmlo0l6NO8tZuv1wR5Wd+
MTi8trPykiiSBuQGWRxTYxoLyGLL5Mg8DEkVSYS+ypiFmWioJ5n5Zr+FbzBkkc0=
-----END CERTIFICATE-----
27 changes: 27 additions & 0 deletions assets/cert/server_key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA7ntoTb4ubZBgu9GLlKSt7G2FM/B8bG75lF+9OnfmkUHYErh/
W81luV7c1p//EoLUcVk52Hmhqn+s6ca1+TUF6VtNbKP57p7I/HW024Yh4p9siWdt
ATN14tiIZ1fl+wrm04xgb4upqnR2TE45Hpo/nKj9Zg/RlCuujcu5LJo5Gd9Z5Q+n
XWipHb/E7ZDHlIBBXVbEnJrf3ksUqsIY8Ex2HwfizF3Y8GcSVhXr1YbFLqs+NXkQ
BTgdmV+QNHWvR7BLl/ZRte3QygaCiIpN1F/Z4IKlQK1ux5ntq/XoBI4lpScRhHpA
FicMWceSVJZD3XQNCu9Z/bcHKnKfDVqF23aCdQIDAQABAoIBACyRs7STzml7ihiP
2N42yKpe7X3/e8FoHAy2t86tidGr1I3rHSIzCMfUCsGxtSHogXuNiVoDoUsUAWTP
VkL0vd4Wyil7m8IUussz1FESiFKqKMalJaIL1ARJI3Ts4HZCW1E98ufl2heZHGK2
W8Z0XV8R1gm0+x4N69lkMX88c196GhgSLZz9Z/x4a9Tx8QPZxsIMvpcKiYkPrlYb
KlEX6k1cynzC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/gin/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/zhaoweiguo/demo-go/github.com/gin-gonic/gin

go 1.16

require github.com/gin-gonic/gin v1.8.1
5 changes: 5 additions & 0 deletions github.com/klauspost/crc32/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


Install using go get github.com/klauspost/crc32. This library is based on Go 1.5 code and requires Go 1.3 or newer.


11 changes: 11 additions & 0 deletions github.com/lucas-clemente/quic-go/demo1/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import (
"github.com/lucas-clemente/quic-go/http3"
"net/http"
)

func main() {
http.Handle("/", http.FileServer(http.Dir(".")))
http3.ListenAndServeQUIC("localhost:4242", "./asserts/cert/server.crt", "./asserts/cert/server_key.pem", nil)
}
5 changes: 5 additions & 0 deletions github.com/yuin/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/zhaoweiguo/demo-go/github.com/yuin

go 1.16

require github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64
5 changes: 5 additions & 0 deletions github.com/yuin/gopher-lua/demo-file/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/zhaoweiguo/demo-go/github.com/yuin/gopher-lua/demo-file

go 1.16

require github.com/yuin/gopher-lua v0.0.0-20220504180219-658193537a64
3 changes: 3 additions & 0 deletions github.com/yuin/gopher-lua/demo-file/hello.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
print("hello world! ..")


13 changes: 13 additions & 0 deletions github.com/yuin/gopher-lua/demo-file/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

import (
lua "github.com/yuin/gopher-lua"
)

func main() {
L := lua.NewState()
defer L.Close()
if err := L.DoFile("./hello.lua"); err != nil {
panic(err)
}
}
3 changes: 3 additions & 0 deletions github.com/yuin/gopher-lua/demo/hello.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
print("hello world")


46 changes: 46 additions & 0 deletions github.com/yuin/gopher-lua/demo/simple_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package demo

import (
"fmt"
lua "github.com/yuin/gopher-lua"
"testing"
)

var (
L *lua.LState
)

func init() {
L = lua.NewState()
}

func TestNormal(t *testing.T) {
defer L.Close()
if err := L.DoString(`print("hello")`); err != nil {
panic(err)
}
}

func TestString(t *testing.T) {
defer L.Close()
lv := L.Get(-1) // get the value at the top of the stack
if str, ok := lv.(lua.LString); ok {
// lv is LString
fmt.Println(string(str))
}
fmt.Println(lv)
if lv.Type() != lua.LTString {
panic("string required.")
}
}

func TestFile(t *testing.T) {
defer L.Close()
if err := L.DoFile("hello.lua"); err != nil {
panic(err)
}
}




14 changes: 6 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/codegangsta/cli v1.20.0
github.com/codegangsta/negroni v1.0.0 // indirect
github.com/coreos/bbolt v1.3.3 // indirect
github.com/coreos/etcd v3.3.18+incompatible
github.com/coreos/etcd v3.3.18+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/dailymotion/allure-go v0.5.5
Expand All @@ -40,7 +40,6 @@ require (
github.com/drone/go-login v1.0.4-0.20190311170324-2a4df4f242a2 // indirect
github.com/drone/go-scm v1.6.1-0.20190930172114-d8fff5ce7761
github.com/drone/signal v1.0.0
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/flant/kubedog v0.3.4 // indirect
github.com/gavv/httpexpect/v2 v2.1.0
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 // indirect
Expand All @@ -50,8 +49,7 @@ require (
github.com/go-ini/ini v1.39.0
github.com/go-kit/kit v0.9.0
github.com/go-redis/redis/v7 v7.0.0-beta.4
github.com/golang/mock v1.4.3
github.com/google/go-cmp v0.5.0
github.com/google/go-cmp v0.5.5
github.com/google/go-jsonnet v0.12.1 // indirect
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc // indirect
github.com/google/wire v0.3.0
Expand All @@ -76,6 +74,7 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/lextoumbourou/goodhosts v2.1.0+incompatible
github.com/lib/pq v1.3.0
github.com/lucas-clemente/quic-go v0.25.0
github.com/mailgun/holster v3.0.0+incompatible // indirect
github.com/mailgun/iptools v0.0.0-20170310010557-ba8d5743f678 // indirect
github.com/mailgun/log v0.0.0-20150926000944-2f35a4607f1a // indirect
Expand Down Expand Up @@ -113,11 +112,10 @@ require (
github.com/vinzenz/yaml v0.0.0-20170920082545-91409cdd725d
go.etcd.io/etcd v3.3.18+incompatible // indirect
go.mongodb.org/mongo-driver v1.0.3
golang.org/x/net v0.0.0-20200707034311-ab3426394381
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/text v0.3.3
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/text v0.3.6
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/grpc v1.29.1
gopkg.in/ahmetb/go-linq.v3 v3.0.0 // indirect
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package main
package array

import (
"fmt"
"testing"
)

func main() {
demo1()
demo2()
}

// 传递数组
func demo1() {
func TestInvoke1(t *testing.T) {
// 在函数间传递变量时,总是以值的方式,如果变量是个数组,那么就会整个复制,并传递给函数,
//如果数组非常大,比如长度100多万,那么这对内存是一个很大的开销。
fmt.Println("===demo1============================")
Expand All @@ -20,7 +17,7 @@ func demo1() {
}

// 传递数组指针
func demo2() {
func TestInvoke2(t *testing.T) {
fmt.Println("===demo2============================")
array := [5]int{1: 2, 3: 4}
modify2(&array)
Expand Down
37 changes: 37 additions & 0 deletions pkg/basic1_type/array/range_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package array

import (
"log"
"testing"
)

func init() {
log.SetFlags(log.Lshortfile)
}


func TestIndex(t *testing.T) {
str := "0123456789"
log.Println(str[:]) // 0123456789
log.Println(str[0:]) // 0123456789
log.Println(str[1:]) // 123456789
log.Println(str[:1]) // 0
log.Println(str[0:9]) // 012345678
log.Println(str[0:10]) // 0123456789
log.Println(str[2:5]) // 234
}

func TestRange1(t *testing.T) {
var myArray [5]int = [5]int{1, 2, 3, 4, 5}
var mySlice []int = myArray[:3]

// result: 1 2 3 4 5
for _, v := range myArray { // _:索引, v:数组值
log.Print(v, "")
}
log.Println()
// result: 1 2 3
for _, v := range mySlice {
log.Print(v, "")
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package main
package array

import (
"fmt"
"testing"
)

func main() {
demo1_byte()
demo2_string()
demo3_int()
demo8_array_point()
demo9_point_array()

}

func demo1_byte() {
func TestByte(t *testing.T) {
fmt.Println("===demo1_byte============================")
// []byte, []uint8
var val []byte = []byte(`"{\"c\":\"b\"}"`) // 这是切片
Expand All @@ -22,7 +16,7 @@ func demo1_byte() {
}
}

func demo2_string() {
func TestString(t *testing.T) {
fmt.Println("===demo2_string============================")
// []string
subsCodes := []string{"aa", "vv", "dd", "ee", "gg"}
Expand All @@ -41,7 +35,7 @@ func demo2_string() {
fmt.Println(car1)
}

func demo3_int() {
func TestInt(t *testing.T) {
fmt.Println("===demo3_int============================")
array := [5]int{1: 1, 3: 4}

Expand All @@ -53,15 +47,15 @@ func demo3_int() {
}

// 数组指针
func demo8_array_point() {
func TestArray_point(t *testing.T) {
fmt.Println("===demo8_array_point============================")
array := [5]int{1: 2, 3: 4}
point := &array
fmt.Println(point, array)
}

// 指针数组
func demo9_point_array() {
func TestPoint_array(t *testing.T) {
//指针数组和数组本身差不多,只不过元素类型是指针
fmt.Println("===demo9_point============================")
array := [5]*int{1: new(int), 3: new(int)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package main
package array

import (
"log"
"testing"
)

/*
Expand All @@ -11,14 +12,7 @@ func init() {
log.SetFlags(log.Lshortfile | log.Ltime)
}

func main() {
demo_array_notchange()
log.Println("==================")
demo_array_change()
log.Println("==================")
}

func demo_array_notchange() {
func TestArray_notchange(t *testing.T) {
// 切片改变数组不变
// 本质其实是类型转换
arr := "Gordon123"
Expand All @@ -40,7 +34,7 @@ func demo_array_notchange() {
log.Printf("[%T]%v", sliceRune, sliceRune)
}

func demo_array_change() {
func TestArray_change(t *testing.T) {
// 基于数组的切片:切片改变,数组就变
arr := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
slice := arr[:5]
Expand All @@ -49,3 +43,8 @@ func demo_array_change() {
log.Printf("[%T]%v", arr, arr)
log.Printf("[%T]%v", slice, slice)
}





22 changes: 0 additions & 22 deletions pkg/basic1_type/array2_range.go

This file was deleted.

Loading

0 comments on commit bc20062

Please sign in to comment.