Easy to use, light enough, good performance Golang library

Overview

English | 简体中文

go.dev reference flat Build Status Go Report Card codecov

luckything

文档

查看文档

建议搭配 zzzzzz watch 指令使用

特性

简单易用、足够轻量,避免过多的外部依赖,最低兼容 Window 7 等老系统

快速上手

安装

$ go get github.com/sohaha/zlsgo

HTTP 服务

// main.go
package main

import (
    "github.com/sohaha/zlsgo/znet"
)

func main(){
    // 获取一个实例
    r := znet.New()

    // 注册路由
    r.GET("/hi", func(c *znet.Context) {
        c.String(200, "Hello world")
     })
    // 隐性路由(结构体绑定)请参考文档
    // 启动
    znet.Run()
}

znet

日志工具

package main

import (
    "github.com/sohaha/zlsgo/zlog"
)

func main(){
    logs := []string{"这是一个测试","这是一个错误"}
    zlog.Debug(logs[0])
    zlog.Error(logs[1])
    zlog.Dump(logs)
    // zlog...
}

zlog

HTTP 客户端

// main.go
package main

import (
    "github.com/sohaha/zlsgo/zhttp"
    "github.com/sohaha/zlsgo/zlog"
)

func main(){
    data, err := zhttp.Get("https://github.com")
    if err != nil {
      zlog.Error(err)
      return
    }
    res := data.String()
    zlog.Debug(res)

}

更多功能

请阅读文档 https://docs.73zls.com/zls-go/#

Todo

  • HTTP 服务端
  • Http 客户端
  • 日志功能
  • Json 处理
  • 字符串处理
  • 验证器
  • 热重启
  • 守护进程
  • 异常上报
  • 终端应用
  • 协程池
  • HTML 解析
  • 数据库操作
  • ...

LICENSE

MIT

You might also like...
A data parser lib for Go with pythonic grammar sugar and as concern as possible for high performance

mapinterface - A data parser lib for Go with pythonic grammar sugar and as concern as possible for high performance mapinterface 旨在消灭对map/list解析而产生的层层

Use Golang to implement PHP's common built-in functions.

PHP2Go Use Golang to implement PHP's common built-in functions. About 140+ functions have been implemented. Install go get github.com/syyongx/php2go R

Color lets you use colorized outputs in terms of ANSI Escape Codes in Go (Golang)
Color lets you use colorized outputs in terms of ANSI Escape Codes in Go (Golang)

Color lets you use colorized outputs in terms of ANSI Escape Codes in Go (Golang). It has support for Windows too! The API can be used in several ways, pick one that suits you.

libraries for various programming languages that make it easy to generate per-process trace files that can be loaded into chrome://tracing
libraries for various programming languages that make it easy to generate per-process trace files that can be loaded into chrome://tracing

chrometracing: chrome://tracing trace_event files The chrometracing directory contains libraries for various programming languages that make it easy t

gqlanalysis makes easy to develop static analysis tools for GraphQL in Go.
gqlanalysis makes easy to develop static analysis tools for GraphQL in Go.

gqlanalysis gqlanalysis defines the interface between a modular static analysis for GraphQL in Go. gqlanalysis is inspired by go/analysis. gqlanalysis

safe and easy casting from one type to another in Go

cast Easy and safe casting from one type to another in Go Don’t Panic! ... Cast What is Cast? Cast is a library to convert between different go types

Easy way to get credentials of your clusters in GCP and stay connected

Easy way to get credentials of your clusters in GCP and stay connected. Don't lose time with alias or annotations with projects names and clusters. Use k8skey

Helpers for making the use of reflection easier

go-xray This is a Golang library with reflection related functions which I use in my different projects. KeyValue This type is used to construct a key

🚀 Use Lanyard API easily in your Go app!

🚀 Go Lanyard Use Lanyard API easily in your Go app! 📦 Installation Initialize your project (go mod init example.com/example) Add package (go get git

Comments
  • http包里的的res.ToFile对windows不友好

    http包里的的res.ToFile对windows不友好

    经测试在windows上,如果用res.ToFile保存文件,会报找不到文件的错误,看了源码之后发现下面这段: nameSplit := strings.Split(name, "/") nameSplitLen := len(nameSplit) if nameSplitLen > 1 { dir := strings.Join(nameSplit[0:nameSplitLen-1], "/") name = zfile.RealPathMkdir(dir) + "/" + nameSplit[nameSplitLen-1] } 在windows上,文件路径是用""分割的,所以nameSplit := strings.Split(name, "/")会导致在windows上失效

    opened by xuyang404 16
  • 中间件问题

    中间件问题

    在使用默认中间件的时候遇到个问题,前端报如下错误: has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

    但是我用如下这种写法却又可以:

    r.Use(cors.New(&cors.Config{
    		Headers:       []string{"Origin", "No-Cache", "X-Requested-With", "If-Modified-Since", "Pragma", "Last-Modified", "Cache-Control", "Expires", "Content-Type", "Access-Control-Allow-Origin"},
    	}))
    

    然而我只是把默认中间件的源码粘出来,就可以了。这是为什么呢?

    opened by xuyang404 14
  • 中间件问题

    中间件问题

    当使用了分组路由时,中间件即使注册为全局中间件也依然不起作用,如:

    //跨域
    	r.Use(cors.Default())
    
    	r.Group("test1", func(e *znet.Engine) {
    		r.GET("/test1/del", delWorker)
    		r.GET("/test1/list", workerList)
    		r.GET("/test1/search", searchWorker)
    	})
    
    	r.Group("test2", func(e *znet.Engine) {
    		r.POST("/test2/save", saveJob)
    		r.POST("/test2/update", updateJob)
    		r.GET("/test2/find", findJob)
    		r.GET("/test2/search", searchJob)
    		r.GET("/test2/list", jobList)
    		r.GET("/test2/del", delJob)
    		r.GET("/test2/kill", killJob)
    		r.GET("/test2/execute", executeJob)
    	})
    
    opened by xuyang404 0
Owner
影浅
w(゚Д゚)w又改需求?
影浅
Robust & Easy to use struct mapper and utility methods for Go

go-model Robust & Easy to use model mapper and utility methods for Go struct. Typical methods increase productivity and make Go development more fun ?

Jeevanandam M. 370 Dec 30, 2022
Easy to use open source hardware to drive WS2811 LEDs with high-quality color

STOP DOING FADECANDY LEDs were not supposed to be given data pins YEARS of "temporal dithering" but no real-world use found for having more than three

Micah Elizabeth Scott 1.2k Dec 29, 2022
🍕 Enjoy a slice! A utility library for dealing with slices and maps that focuses on type safety and performance.

?? github.com/elliotchance/pie Enjoy a slice! pie is a library of utility functions for common operations on slices and maps. Quick Start FAQ What are

Elliot Chance 1.2k Dec 30, 2022
Use controllers with the Gorilla Mux library

Gorilla Controllers Use controllers with the Gorilla Mux library Why controllers? Gorilla's mux library is a brilliant fully featured mux tool, Gorill

Joe Gasewicz 6 Nov 22, 2022
Use is a go utility library using go1.18 generics

use use is a go utility library using go1.18 generics created by halpdesk 2022-01-22 use/slice Map updates a slice by applying a function to all membe

halpdesk 0 Jan 22, 2022
An easy way to getsystem by golang.

doge-getsys An easy way to getsystem by golang. getsystem From administrator to System usage doge-getsys.exe open a new cmd window in system privileg

TimWhite 53 Jan 1, 2023
this is a easy breaker by golang code

tfgo-breaker 1. Intro This is a easy breaker by golang code. U can use it in your project quickly. Support function break, timeout, auto dry-run. 2. D

Lion 78 Sep 17, 2022
efaceconv - Code generation tool for high performance conversion from interface{} to immutable type without allocations.

efaceconv High performance conversion from interface{} to immutable types without additional allocations This is tool for go generate and common lib (

Ivan 50 May 14, 2022
Perforator is a tool for recording performance metrics over subregions of a program using the Linux "perf" interface.

Perforator Perforator is a tool for recording performance metrics over subregions of a program (e.g., functions) using the Linux "perf" interface.

Zachary Yedidia 34 Dec 15, 2022
Continuous profiling for analysis of CPU, memory usage over time, and down to the line number. Saving infrastructure cost, improving performance, and increasing reliability.

Continuous profiling for analysis of CPU, memory usage over time, and down to the line number. Saving infrastructure cost, improving performance, and increasing reliability.

Parca 2.8k Jan 2, 2023