分类目录归档:后端语言

顺序栈的定义与基础操作


#include <stdio.h>
#include <stdlib.h>

#define MaxSize 10
#define bool char
#define True 1
#define False 0

typedef int ElemType;

// 顺序栈类型定义
typedef struct stack {
    ElemType data[MaxSize];
    int top;
} SeqStack;


void init(SeqStack *s) {
    s->top = -1;
};

bool is_empty(S...

Read more

栈的链式存储结构及基本操作


#include <stdio.h>
#include <stdlib.h>

#define MaxSize 10
#define ElemType int
#define bool char
#define True 1
#define False 0

struct node {
    ElemType data;
    struct node *next;
};

struct node *top;

void init() {
    top = NULL;
}

bool is_empty() {
    if (top == NULL) {
  ...

Read more

Cmake基础用法


# CMakeLists.txt 文件常用配置
# cmake最小版本
cmake_minimum_required(VERSION 3.10)

# 项目名
project(demo1)

# 设置bin目录
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

# 将源文件目录下所有源文件保存到SRC_LIST
aux_source_directory(src SRC_LIST)

# 指定头文件目录
include_directories(include)

# 将所有源文件编译成二进制程序
add_executable(d...

Read more

Gin框架表单验证


package main

import (
    "fmt"
    "github.com/gin-gonic/gin"
    "github.com/gin-gonic/gin/binding"
    "github.com/go-playground/locales/en"
    "github.com/go-playground/locales/zh"
    ut "github.com/go-playground/universal-translator&q...

Read more

grpc和protobuf


grpc

gRPC 是一个高性能、开源和通用的 RPC 框架,面向移动和 HTTP/2 设计。目前提供 C、Java 和 Go 语言版本,分别是:grpc, grpc-java, grpc-go. 其中 C 版本支持 C, C++, Node.js, Python, Ruby, Objective-C, PHP 和 C# 支持. grpc/grpc The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) - grpc/grpc

Protocol Buffer

其实 是 Google出品的一种轻量 & 高效的结构化数...

Read more

zerorpc


ZeroRPC是一个轻量级,可靠且与语言无关的产品 用于服务器端之间分布式通信的库 过程。它建立在ZeroMQ和MessagePack之上。 支持流响应 - 类似于 python 生成器 - 使 ZeroRPC 比典型的 RPC 引擎更多。内置 检测信号和超时检测故障并从故障中恢复 请求。内省能力,一流例外 命令行实用程序使调试变得容易。

# 安装zerorpc 
pip install  zerorpc

# 启动内置服务
zerorpc --server --bind tcp://*:1234 time
zerorpc --client --connect tcp://127.0...

Read more

Go基础语法练习(4)


Server

package main

import (
    "fmt"
    "net"
)

func main() {
    // 1.创建监听
    ip := "127.0.0.1"
    port := 8080
    address := fmt.Sprintf("%s:%d", ip, port)
    server, err := net.Listen("tcp", address)
    defer server.Close()
    if err...

Read more

Go基础语法练习(3)


package main

import (
    "fmt"
    "strconv"
    "time"
)

func display() {
    for i := 0; i < 10; i++ {
        fmt.Println("协程display", i)
        time.Sleep(1 * time.Second)
        //if i == 3 {
        //  // 退出当前的协程
        //  // runtime.Goexit...

Read more

Go基础语法练习(2)


package main

import (
    "fmt"
    "os"
)

func init() {
    // 每个包中第一个执行的函数,import时自动执行,不能被用户调用
    // 没有参数,没有返回值
    // 包中包含多个init时,调用顺序不确定
    fmt.Println("Hello Init")
}

func main() {
    //switchTest()
    //gotoTest()
    //enumTest()
    //structTest()
    ...

Read more

Go基础语法练习(1)


package main

import (
    "fmt"
    "strconv"
)

func main() {
    zTest()
    fibo()
    strTest()
    arrayTest()
    sliceTest()
    mapTest()
    a, b, c := funTest(1, 3, "Code ")
    fmt.Println(a, b, c)

}

func funTest(a int, b int, c string) (int, bool, stri...

Read more