chinasoftbeigodriver

package module
v0.0.0-...-febb8e8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 6 Imported by: 0

README

中软杯算法接入GoDriver

install

go get gitee.com/allo123/chinasoftbeigodriver

usage

import (
    driver "gitee.com/allo123/chinasoftbeigodriver"
)

// get database list
dbList, err := driver.GetDBList()
if err != nil {
    // error handling
}

// send result back
driver.SendData(result)

// get Args
driver.Args

example

Hello World Demo

package main

import (
    driver "gitee.com/allo123/chinasoftbeigodriver"
)

func main() {
    dbList, err := driver.GetDBList()
    if err != nil {
        os.Exit(-1)
    }
    if len(dbList) != 0 {
        driver.SendData([]byte(dbList[0].DBAddr+"\n"))
    }
    driver.SendData([]byte("Hello World."))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Args 算法参数 (Not inclued os.Args[0])
	Args []string
	// ErrNoResponse no response error
	ErrNoResponse = errors.New("No response")
	// ErrStatusErr status error
	ErrStatusErr = errors.New("Status error")
)

Functions

func SendData

func SendData(data []byte) error

SendData send data to server

Types

type DBInfo

type DBInfo struct {
	Type     DBName `json:"type"`
	Addr     string `json:"addr"`
	Database string `json:"database"`
	UserName string `json:"username"`
	Password string `json:"password"`
}

DBInfo database info

func GetDBList

func GetDBList() (dbList []DBInfo, err error)

GetDBList get database list

type DBName

type DBName string

DBName database name

const (
	// Influxdb database name of influxdb
	Influxdb DBName = "influxdb"
	// Mysql database name of mysql
	Mysql DBName = "mysql"
	// SQL database name of SQL
	SQL DBName = "sqlserver"
)

type WarningMsg

type WarningMsg struct {
	Msg            string         `json:"msg"`
	OutOfResources []string       `json:"outOfResources"`
	Resources      map[string]int `json:"resources"`
}

WarningMsg 预警信息

Jump to

Keyboard shortcuts

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