Ghost

module
v0.0.0-...-d73eb14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2019 License: GPL-2.0

README

#Ghost Ghost基本库

  • 通用库 -- 只是常用功能库的集中地【文件相关 日志相关 加密相关 随机数GUID相关】
  • 服务库 -- 微服务管理器
  • 网络库 -- 目前封装了TCP通讯功能 基于protobuf
  • 网络库 -- 封装了websocket通讯功能 基于protobuf json
  • web框架 -- web开发框架基于插件组合式的
  • 数据库 -- 准备使用orm封装还没开始做 关系型数据库
  • 缓存DB库 -- 基于redis封装
  • 消息队列 -- 基于NSQ封装

:反射了解教程 http://www.jb51.net/article/115002.htm :Windows服务 github.com/kardianos/service #使用方法1

package main
import (
	. "Ghost/utd"
)
func main() {
	Usys.Exec(func(){
		Usys.Print("something")
	}<!-- ,nil -->)
}

#使用方法2

package main

import (
	"Ghost/cmd"
	"Ghost/mss"
	. "Ghost/utd"
)

const SID_CONSOLE_INPUT = mss.DEF_SERVICE_ID_BGN + iota

func init() {
	mss.Regist(SID_CONSOLE_INPUT, &cmd.CommandLine{})
}

func main() { mss.Run(nil,nil) }

#使用方法3[service]

package main
import (
	"Ghost/cmd"
	"Ghost/mss"
	. "Ghost/utd"
	"github.com/kardianos/service"
	"os"
)

const SID_CONSOLE_INPUT = mss.DEF_SERVICE_ID_BGN + iota

func init() {
	mss.Regist(SID_CONSOLE_INPUT, &cmd.CommandLine{})
}

type program struct{}

func (p *program) init() bool {
	if len(os.Args) > 1 && (os.Args[1] == "-I" || os.Args[1] == "-U" || os.Args[1] == "-S") {
		svcConfig := &service.Config{
			Name:        "GoServiceExampleSimple",         //服务显示名称
			DisplayName: "Go Service Example",             //服务名称
			Description: "This is an example Go service.", //服务描述
			Arguments:   []string{"-S", "-LogLevel=2", "-LogDirName=log", "-Config=./Config.cfg"},
		}

		s, err := service.New(&program{}, svcConfig)
		if err != nil {
			Usys.Print("err:%v", err)
			return false
		}

		switch os.Args[1] {
		case "-I":
			if err = s.Install(); err != nil {
				Usys.Print("Service Installation err:%v.", err)
			} else {
				Usys.Print("Service Installation successful.")
			}
		case "-U":
			if err = s.Uninstall(); err != nil {
				Usys.Print("Service Installation err:%v.", err)
			} else {
				Usys.Print("Service uninstallation successful.")
			}
		case "-S":
			if err = s.Run(); err != nil {
				Usys.Print("Service Run err:%v", err)
			}
		}
		return false
	}
	return true
}
func (p *program) Start(s service.Service) error {
	go p.Work()
	return nil
}
func (p *program) Stop(s service.Service) error {
	Usys.Quit()
	return nil
}
func (p *program) Work() {
	mss.Run(nil,nil)
}

func main() {
	prg := &program{}
	Ucom.UCast(prg.init(), func() { prg.Work() }, nil)
}

统计代码行数: ^b*[^:b#/]+.*$

// win下交叉编译linux程序 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build

// 性能分析工具 浏览器 查看概览 http://localhost:6060/debug/pprof/

命令行 分析堆 go tool pprof http://localhost:6060/debug/pprof/heap  命令行 分析cpu go tool pprof http://localhost:6060/debug/pprof/profile 命令行 分析mem go tool pprof http://localhost:6060/debug/pprof/block  命令行 火焰图 go tool pprof -http="127.0.0.1:8088" http://127.0.0.1:8080/debug/pprof/profile

Directories

Path Synopsis
Code generated by protoc-gen-go.
Code generated by protoc-gen-go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL