Giter Club home page Giter Club logo

mix's Introduction

Produced by OpenMix: https://openmix.org



MixPHP

Mix Go

English | 中文

MixGo is a Go rapid development standard toolkit; the internal modules are highly decoupled, and the overall code is built on multiple independent modules. Even if users do not use our mixcli scaffolding to quickly generate code, they can also use these independent modules. For example: you can use xcli alone to build your command-line interaction; use xsql to call the database; use xwp to handle MQ queue consumption; you can freely combine all modules like building blocks.

Independent Modules

All core modules can be used independently.

  • mix-go/mixcli Scaffold to quickly create Go projects, similar to Vue CLI in the frontend field.
  • mix-go/xcli Command-line interaction and command management tool, also includes command-line parameter acquisition, middleware, program daemon, etc.
  • mix-go/xsql Lightweight database based on database/sql, fully functional and supports any database driver.
  • mix-go/xrpc Assistant for gRPC and Gateway.
  • mix-go/xdi IoC, DI library for handling object dependencies, can implement unified dependency management, global object management, dynamic configuration refresh, etc.
  • mix-go/xwp A universal work pool, coroutine pool, can dynamically expand and shrink.
  • mix-go/xhttp A highly efficient HTTP library.
  • mix-go/xutil A set of tools to keep Golang sweet.

Development Documentation

Quick Start

Provides ready-to-use scaffolding tools to quickly create projects and produce immediate output.

go install github.com/mix-go/mixcli@latest
$ mixcli new hello
Use the arrow keys to navigate: ↓ ↑ → ← 
? Select project type:
  ▸ CLI
    API
    Web (contains the websocket)
    gRPC

If there is an error during compilation, tidy up the dependencies.

go mod tidy

Goland

Examples

AD CONNMIX Gateway

CONNMIX Gateway - Programmable distributed long connection gateway

  • Can be used for chat rooms, live pop-ups, IM instant messaging, online customer service, online games, hardware communication, smart home, IoT and other areas of development
  • A few lines of code, free to get socket, websocket real-time communication

Technical Discussion

Zhihu: https://www.zhihu.com/people/onanying
Official QQ Group: 284806582, 825122875 Secret Password: gopher

PHP Framework

OpenMix also has PHP ecosystem frameworks:

License

Apache License Version 2.0, http://www.apache.org/licenses/

mix's People

Contributors

beyoung avatar cexll avatar charlerive avatar dependabot[bot] avatar lackoxygen avatar onanying avatar sy-records avatar utilbox avatar yinhuanhuan avatar yupeng2015 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mix's Issues

运行示例应用报错

golang纯小白, 运行示例应用报错

平台

raspberry pi 2 model b

系统

Linux ubuntu 5.4.0-1022-raspi #25-Ubuntu SMP PREEMPT Thu Oct 15 14:22:53 UTC 2020 armv7l armv7l armv7l GNU/Linux

报错信息

ubuntu@ubuntu:~/projects/hello/bin$ ./go_build_main_go api
time=2020-11-13 08:18:05.454 level=error msg=dial tcp 127.0.0.1:3306: connect: connection refused
goroutine 1 [running]:
runtime/debug.Stack(0x69c658, 0x1288060, 0x6da108)
        /usr/lib/go-1.13/src/runtime/debug/stack.go:24 +0x78
github.com/mix-go/console.(*ErrorHandler).Handle(0x100e9e0, 0x6d43d8, 0x1282050)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/error.go:52 +0x60
github.com/mix-go/console.(*Application).Run.func1(0x12932c0)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/application.go:122 +0xc4
panic(0x6d43d8, 0x1282050)
        /usr/lib/go-1.13/src/runtime/panic.go:679 +0x194
github.com/mix-go/bean.(*BeanDefinition).instance.func1.1(0x1286ae0, 0x12139ac)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/definition.go:94 +0x16c
panic(0x6d43d8, 0x1282050)
        /usr/lib/go-1.13/src/runtime/panic.go:679 +0x194
github.com/mix-go/bean.(*BeanDefinition).instance.func1(0x1286ae0, 0x12139ac, 0x100d540, 0x2, 0x2)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/definition.go:102 +0x1b0
github.com/mix-go/bean.(*BeanDefinition).instance(0x1286ae0, 0x6c0750, 0x1213bbc)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/definition.go:106 +0x2d4
github.com/mix-go/bean.(*ApplicationContext).GetBean(0x12c54c0, 0x774aa5, 0x2, 0x1213c14, 0x1213bec, 0x0, 0x0, 0x75fe58, 0x1010680)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/context.go:60 +0x118
github.com/mix-go/bean.(*ApplicationContext).Get(...)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/context.go:69
github.com/mix-go/console.(*Application).Get(...)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/application.go:109
hello/globals.DB(...)
        /home/ubuntu/projects/hello/globals/db.go:9
hello/globals.Init()
        /home/ubuntu/projects/hello/globals/init.go:23 +0x220
hello/listeners.(*CommandListener).Process(0xd32aa0, 0x87eb50, 0x1010710)
        /home/ubuntu/projects/hello/listeners/command.go:24 +0x3c
github.com/mix-go/event.(*ListenerProvider).getListenersForEvent.func1(0x87eb50, 0x1010710)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/provider.go:17 +0x38
github.com/mix-go/event.(*EventDispatcher).Dispatch(0x1010618, 0x87eb50, 0x1010710, 0xe1901, 0x4)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/dispatcher.go:11 +0x80
github.com/mix-go/console.(*Application).call(0x12932c0)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/application.go:202 +0x120
github.com/mix-go/console.(*Application).Run(0x12932c0)
        /home/ubuntu/go/pkg/mod/github.com/mix-go/[email protected]/application.go:161 +0x3b4
main.main()
        /home/ubuntu/projects/hello/main.go:28 +0xac
 file=logger.go:19

API模式下数据库的使用

根据文档使用Gorm的方法:

db := di.Gorm()
user := User{Name: "Jinzhu", Age: 18, Birthday: time.Now()}
result := db.Create(&user)
fmt.Println(result)

在Controller实现数据库查询业务时,对于db := di.Gorm()的使用,应该每次都db := di.Gorm()创建一个新的db变量,还是在某个位置声明并创建一个全局的db变量,所有controller公用这个db变量?

开发环境怎么运行呢

只能每次build 然后运行吗, 直接 go run mian.go 会提示配置文件路径错误,需要去改 viper 或者 dotnev 读取路径

关于di/gorm.go

如果数据库服务重启,gorm.go会panic,整个app就crash了。。

有一个小问题

对于子命令的帮助,只支持--help 不支持 -h
myapp command1 -help
不支持
myapp command1 -h

编译及运行main.go出错,安装了console,api,web

按照文档demo,一步步做:
https://www.kancloud.cn/onanying/mixgo1/1894807
错误信息:

go build -o bin/go_build_main_go.exe main.go
# hello/commands
commands\server.go:15:7: Addr redeclared in this block
        previous declaration at commands\api.go:21:14
commands\web.go:22:7: Addr redeclared in this block
        previous declaration at commands\server.go:15:14

提示显示可能是端口冲突,改了commands/api.go 里的端口为 8081,改commands/web.go里的端口为8082,server.go里没有动(8080)。接着跑还是报这个错误。

编辑器使用的:vscode. 安装的插件:go 0.18.1

Can you introduce the framework loading process of the following rectification projects? Because gin's default loading process, such as DB Error Logger, is for a Beans instance. These components, if a server provided by GIN is not available, how to replenish the corresponding Error message instead of the service being unavailable due to panic

Can you introduce the framework loading process of the following rectification projects? Because gin's default loading process, such as DB Error Logger, is for a Beans instance. These components, if a server provided by GIN is not available, how to replenish the corresponding Error message instead of the service being unavailable due to panic

配置解决方案

作者可以考虑一下内置viper库来提供选择,现在很多项目用viper的挺多的。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.