github.com/sohaha/zlsgo@v1.7.13-0.20240501141223-10dd1a906f76/README.md (about)

     1  [English](./README.EN.md) | 简体中文
     2  
     3  ![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/sohaha/zlsgo)
     4  ![flat](https://img.shields.io/github/languages/top/sohaha/zlsgo.svg?style=flat)
     5  [![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/sohaha/zlsgo?tab=subdirectories)
     6  [![UnitTest](https://github.com/sohaha/zlsgo/actions/workflows/go.yml/badge.svg)](https://github.com/sohaha/zlsgo/actions/workflows/go.yml)
     7  [![Go Report Card](https://goreportcard.com/badge/github.com/sohaha/zlsgo)](https://goreportcard.com/report/github.com/sohaha/zlsgo)
     8  [![codecov](https://codecov.io/gh/sohaha/zlsgo/branch/master/graph/badge.svg)](https://codecov.io/gh/sohaha/zlsgo)
     9  
    10  ![luckything](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fa4bcc6b2-32ef-4a7d-ba1c-65a0330f632d%2Flogo.png?table=block&id=37f366ec-0593-4a21-94c0-c24023a85354&width=590&cache=v2)
    11  
    12  ## 文档
    13  
    14  [查看文档](https://docs.73zls.com/zls-go/#)
    15  
    16  建议搭配 [zzz](https://github.com/sohaha/zzz) 的 `zzz watch` 指令使用
    17  
    18  ## 特性
    19  
    20  简单易用、足够轻量,避免过多的外部依赖,最低兼容 Window 7 等老系统
    21  
    22  ## 快速上手
    23  
    24  ### 安装
    25  
    26  ```bash
    27  $ go get github.com/sohaha/zlsgo
    28  ```
    29  
    30  ### HTTP 服务
    31  
    32  ```go
    33  // main.go
    34  package main
    35  
    36  import (
    37      "github.com/sohaha/zlsgo/znet"
    38  )
    39  
    40  func main(){
    41      // 获取一个实例
    42      r := znet.New()
    43  
    44      // 注册路由
    45      r.GET("/hi", func(c *znet.Context) {
    46          c.String(200, "Hello world")
    47       })
    48      // 隐性路由(结构体绑定)请参考文档
    49      // 启动
    50      znet.Run()
    51  }
    52  ```
    53  
    54  ![znet](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2F1d7f2372-5d58-4848-85ca-1bedf8ad14ae%2FUntitled.png?table=block&id=18fdfaa9-5dab-4cb8-abb3-f19ff37ed3f0&width=2210&userId=&cache=v2)
    55  
    56  ### 日志工具
    57  
    58  ```go
    59  package main
    60  
    61  import (
    62      "github.com/sohaha/zlsgo/zlog"
    63  )
    64  
    65  func main(){
    66      logs := []string{"这是一个测试","这是一个错误"}
    67      zlog.Debug(logs[0])
    68      zlog.Error(logs[1])
    69      zlog.Dump(logs)
    70      // zlog...
    71  }
    72  ```
    73  
    74  ![zlog](https://www.notion.so/image/https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fsecure.notion-static.com%2Fd8cc2527-8d9d-466c-b5c8-96e706ee0691%2FUntitled.png?table=block&id=474726aa-05fd-47ba-b270-59017c59817b&width=2560&cache=v2)
    75  
    76  ### HTTP 客户端
    77  
    78  ```go
    79  // main.go
    80  package main
    81  
    82  import (
    83      "github.com/sohaha/zlsgo/zhttp"
    84      "github.com/sohaha/zlsgo/zlog"
    85  )
    86  
    87  func main(){
    88      data, err := zhttp.Get("https://github.com")
    89      if err != nil {
    90        zlog.Error(err)
    91        return
    92      }
    93      res := data.String()
    94      zlog.Debug(res)
    95  
    96  }
    97  ```
    98  
    99  ### 更多功能
   100  
   101  请阅读文档 [https://docs.73zls.com/zls-go/#](https://docs.73zls.com/zls-go/#)
   102  
   103  ## Todo
   104  
   105  - [x] HTTP 服务端
   106  - [x] Http 客户端
   107  - [x] JSON RPC
   108  - [x] 日志功能
   109  - [x] Json 处理
   110  - [x] 字符串处理
   111  - [x] 验证器
   112  - [x] 热重启
   113  - [x] 守护进程
   114  - [x] 异常上报
   115  - [x] 终端应用
   116  - [x] 协程池
   117  - [x] HTML 解析
   118  - [x] 依赖注入
   119  - [x] Server Sent 推送
   120  - [x] 高性能 HashMap
   121  - [ ] [数据库操作](https://github.com/sohaha/zdb)
   122  - [ ] ...(更多请阅读[文档](https://docs.73zls.com/zls-go/#))
   123  
   124  ## LICENSE
   125  
   126  [MIT](LICENSE)