Browse Source

整理项目

liuyuqi-dellpc 5 years ago
parent
commit
580000d72e

+ 13 - 0
README.md

@@ -1,2 +1,15 @@
 # Go_Tools
 
+	* basic
+	* calc
+	* class
+	* file
+	* main
+	* math
+	* net
+	* project
+		-web 
+
+		
+## project		
+一个工程目录结构如下:

+ 0 - 0
docs/Go基础.md


+ 0 - 0
docs/Go语言介绍.md


+ 17 - 0
docs/并发编程.md

@@ -0,0 +1,17 @@
+4.1 并发基础
+4.2 协程
+4.3 goroutine
+4.4 并发通信
+4.5 channel
+4.5.1 基本语法
+4.5.2 select
+4.5.3 缓冲机制
+4.5.4 超时机制
+4.5.5 channel的传递
+4.5.6 单向channel
+4.5.7 关闭channel
+4.6 多核并行化
+4.7 出让时间片
+4.8 同步
+4.8.1 同步锁
+4.8.2 全局唯一性操作

+ 17 - 0
docs/网络编程.md

@@ -0,0 +1,17 @@
+5.1 Socket编程
+5.1.1 Dial()函数
+5.1.2 ICMP示例程序
+5.1.3 TCP示例程序
+5.1.4 更丰富的网络通信
+5.2 HTTP编程
+5.2.1 HTTP客户端
+5.2.2 HTTP服务端
+5.3 RPC编程
+5.3.1 Go语言中的RPC支持与处理
+5.3.2 Gob简介
+5.3.3 设计优雅的RPC接口
+5.4 JSON处理
+5.4.1 编码为JSON格式
+5.4.2 解码JSON数据
+5.4.3 解码未知结构的JSON数据
+5.4.4 JSON的流式读写

+ 9 - 0
docs/面向对象编程.md

@@ -0,0 +1,9 @@
+# 类
+Go语言没有继承、虚函数、构造函数和析构函数、隐藏的this指针等。在Go语言中,你可以给任意类型(包括内置类型,但不包括指针类型)添加相应的方法。go没有class关键字,而是对各种变量包括自定义变量可以设置相应的方法,比如定义一个学生类,以及设置学生姓名等方法:
+
+## 初始化
+
+## 可见性
+
+
+# 接口

+ 3 - 0
docs/项目开发-web-beego框架.md

@@ -0,0 +1,3 @@
+# go语言用到很多地方
+
+

+ 7 - 0
src/basic/print.go

@@ -0,0 +1,7 @@
+package basic
+
+import (
+	"fmt"
+)
+
+

+ 83 - 0
src/project/web/beego/Makefile

@@ -0,0 +1,83 @@
+LDFLAGS += -X "github.com/gogits/gogs/pkg/setting.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
+LDFLAGS += -X "github.com/gogits/gogs/pkg/setting.BuildGitHash=$(shell git rev-parse HEAD)"
+
+DATA_FILES := $(shell find conf | sed 's/ /\\ /g')
+LESS_FILES := $(wildcard public/less/gogs.less public/less/_*.less)
+GENERATED  := pkg/bindata/bindata.go public/css/gogs.css
+
+OS := $(shell uname)
+
+TAGS = ""
+BUILD_FLAGS = "-v"
+
+RELEASE_ROOT = "release"
+RELEASE_GOGS = "release/gogs"
+NOW = $(shell date -u '+%Y%m%d%I%M%S')
+GOVET = go tool vet -composites=false -methods=false -structtags=false
+
+.PHONY: build pack release bindata clean
+
+.IGNORE: public/css/gogs.css
+
+all: build
+
+check: test
+
+dist: release
+
+web: build
+	./gogs web
+
+govet:
+	$(GOVET) gogs.go
+	$(GOVET) models pkg routes
+
+build: $(GENERATED)
+	go install $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)'
+	cp '$(GOPATH)/bin/gogs' .
+
+build-dev: $(GENERATED) govet
+	go install $(BUILD_FLAGS) -tags '$(TAGS)'
+	cp '$(GOPATH)/bin/gogs' .
+
+build-dev-race: $(GENERATED) govet
+	go install $(BUILD_FLAGS) -race -tags '$(TAGS)'
+	cp '$(GOPATH)/bin/gogs' .
+
+pack:
+	rm -rf $(RELEASE_GOGS)
+	mkdir -p $(RELEASE_GOGS)
+	cp -r gogs LICENSE README.md README_ZH.md templates public scripts $(RELEASE_GOGS)
+	rm -rf $(RELEASE_GOGS)/public/config.codekit $(RELEASE_GOGS)/public/less
+	cd $(RELEASE_ROOT) && zip -r gogs.$(NOW).zip "gogs"
+
+release: build pack
+
+bindata: pkg/bindata/bindata.go
+
+pkg/bindata/bindata.go: $(DATA_FILES)
+	go-bindata -o=$@ -ignore="\\.DS_Store|README.md|TRANSLATORS" -pkg=bindata conf/...
+
+less: public/css/gogs.css
+
+public/css/gogs.css: $(LESS_FILES)
+	lessc $< $@
+
+clean:
+	go clean -i ./...
+
+clean-mac: clean
+	find . -name ".DS_Store" -print0 | xargs -0 rm
+
+test:
+	go test -cover -race ./...
+
+fixme:
+	grep -rnw "FIXME" cmd routers models pkg
+
+todo:
+	grep -rnw "TODO" cmd routers models pkg
+
+# Legacy code should be remove by the time of release
+legacy:
+	grep -rnw "LEGACY" cmd routers models pkg

+ 0 - 0
src/project/web/beego/README.md


+ 10 - 0
src/project/web/beego/auto-deploy-local.sh

@@ -0,0 +1,10 @@
+#! /bin/bash
+echo 'update code'
+git reset HEAD --hard
+git pull origin master
+echo 'pack'
+bee pack -be GOOS=linux -exr='^[0-9a-f]|[*.iml]$'
+echo 'upload'
+scp beepkg.tar.gz  jjz@192.168.1.10:/root/goapp/beepkg
+echo 'restart'
+ssh jjz@192.168.1.10 'bash -s' < restart.sh

+ 9 - 0
src/project/web/beego/auto-deploy-remote.sh

@@ -0,0 +1,9 @@
+#! /bin/bash
+#默认进入的是登录用户的目录
+
+cd test/bee
+tar -xzvf beepkg.tar.gz
+#remove conf of dev
+rm -rf conf/app.conf
+cp conf/app.conf.bat conf/app.conf
+supervisorctl restart beepkg

+ 1 - 0
src/project/web/beego/cmd/admin.go

@@ -0,0 +1 @@
+package cmd

+ 13 - 0
src/project/web/beego/cmd/backup.go

@@ -0,0 +1,13 @@
+package cmd
+
+import (
+	"github.com/urfave/cli"
+)
+
+var Backup = cli.Command{
+}
+
+const _ARCHIVE_ROOT_DIR = "gogs-backup"
+
+func runBackup(c *cli.Context) error {
+}

+ 37 - 0
src/project/web/beego/cmd/cmd.go

@@ -0,0 +1,37 @@
+package cmd
+
+import (
+	"time"
+	"github.com/urfave/cli"
+)
+
+func stringFlag(name, value, usage string) cli.StringFlag {
+	return cli.StringFlag{
+		Name:  name,
+		Value: value,
+		Usage: usage,
+	}
+}
+
+func boolFlag(name, usage string) cli.BoolFlag {
+	return cli.BoolFlag{
+		Name:  name,
+		Usage: usage,
+	}
+}
+
+func intFlag(name string, value int, usage string) cli.IntFlag {
+	return cli.IntFlag{
+		Name:  name,
+		Value: value,
+		Usage: usage,
+	}
+}
+
+func durationFlag(name string, value time.Duration, usage string) cli.DurationFlag {
+	return cli.DurationFlag{
+		Name:  name,
+		Value: value,
+		Usage: usage,
+	}
+}

+ 1 - 0
src/project/web/beego/cmd/hook.go

@@ -0,0 +1 @@
+package cmd

+ 1 - 0
src/project/web/beego/cmd/import.go

@@ -0,0 +1 @@
+package cmd

+ 2 - 0
src/project/web/beego/cmd/web.go

@@ -0,0 +1,2 @@
+package cmd
+

+ 3 - 0
src/project/web/beego/conf/app.conf

@@ -0,0 +1,3 @@
+appname = test2-go
+httpport = 8080
+runmode = dev

+ 18 - 0
src/project/web/beego/controllers/default.go

@@ -0,0 +1,18 @@
+package controllers
+
+import (
+	"github.com/astaxie/beego"
+)
+
+type MainController struct {
+	beego.Controller
+}
+
+func (c *MainController) Get() {
+	c.Data["Website"] = "beego.me"
+	c.Data["Email"] = "lyq@yoqi.me"
+	c.TplName = "index.tpl"
+}
+func (c *MainController)GetUser()  {
+	
+}

+ 26 - 0
src/project/web/beego/main.go

@@ -0,0 +1,26 @@
+package main
+
+import (
+	_ "test2-go/routers"
+	"github.com/urfave/cli"
+	"os"
+)
+
+const APP_VER = "0.1.0.0"
+
+func init()  {
+	setting.AppVer = APP_VER
+}
+func main() {
+	app := cli.NewApp()
+	app.Name = "test1-go"
+	app.Usage = "描述x.x"
+	app.Version = APP_VER
+	app.Commands = []cli.Command{
+		cmd.Web,
+		cmd.BackUp,
+	}
+	app.Flags = append(app.Flags, []cli.Flag{}...)
+	app.Run(os.Args)
+}
+

+ 10 - 0
src/project/web/beego/routers/router.go

@@ -0,0 +1,10 @@
+package routers
+
+import (
+	"test1-go/test2-go/controllers"
+	"github.com/astaxie/beego"
+)
+
+func init() {
+    beego.Router("/", &controllers.MainController{})
+}

+ 1 - 0
src/project/web/beego/static/js/reload.min.js

@@ -0,0 +1 @@
+function b(a){var c=new WebSocket(a);c.onclose=function(){setTimeout(function(){b(a)},2E3)};c.onmessage=function(){location.reload()}}try{if(window.WebSocket)try{b("ws://localhost:12450/reload")}catch(a){console.error(a)}else console.log("Your browser does not support WebSockets.")}catch(a){console.error("Exception during connecting to Reload:",a)};

+ 39 - 0
src/project/web/beego/tests/default_test.go

@@ -0,0 +1,39 @@
+package test
+
+import (
+	"net/http"
+	"net/http/httptest"
+	"testing"
+	"runtime"
+	"path/filepath"
+	_ "test2-go/routers"
+
+	"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)
+}
+
+
+// TestBeego is a sample to run an endpoint test
+func TestBeego(t *testing.T) {
+	r, _ := http.NewRequest("GET", "/", nil)
+	w := httptest.NewRecorder()
+	beego.BeeApp.Handlers.ServeHTTP(w, r)
+
+	beego.Trace("testing", "TestBeego", "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)
+	        })
+	})
+}
+

File diff suppressed because it is too large
+ 29 - 0
src/project/web/beego/views/index.tpl


Some files were not shown because too many files changed in this diff