欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

golang?四則運(yùn)算計(jì)算器yacc歸約手寫實(shí)現(xiàn)

 更新時(shí)間:2022年07月12日 11:27:15   作者:ioly  
這篇文章主要為大家介紹了golang?四則運(yùn)算?計(jì)算器?yacc?歸約的手寫實(shí)現(xiàn),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

緣起

最近拜讀前橋和彌[日]的<<自制編程語(yǔ)言>>

開頭一章便是教讀者使用lex/yacc工具

制作四則運(yùn)算器

其中yacc的移進(jìn)/歸約/梯度下降的思想很有啟發(fā)

于是使用golang練習(xí)之

目標(biāo)

  • 制作一個(gè)四則運(yùn)算器, 從os.Stdin讀入一行表達(dá)式, 然后輸出計(jì)算過程和結(jié)果
  • 支持+ - * /
  • 支持左右括號(hào)
  • 支持負(fù)數(shù)

難點(diǎn)

記號(hào)掃描(lexer)

  • 逐字符掃描記號(hào)
  • 單字符記號(hào)可直接識(shí)別, + - * / ( )

多字符記號(hào), 此處只有浮點(diǎn)數(shù), 通過有限狀態(tài)的轉(zhuǎn)換進(jìn)行識(shí)別

<INITIAL> + '-' = INT_STATUS

<INITIAL> + 'd' = INT_STATUS

<INT_STATUS> + '.' = DOT_STATUS

<INT_STATUS> + 'SPACE | + | - | * | / | ( | )' = INITIAL

<DOT_STATUS> + 'd' = FRAG_STATUS

<FRAG_STATUS> + 'SPACE | + | - | * | / | ( | )' = INITIAL

運(yùn)算優(yōu)先級(jí)

  • /優(yōu)先級(jí)最高, 可以立即歸約計(jì)算
  • 括號(hào)次之, 遇到右括號(hào), 應(yīng)當(dāng)觸發(fā)+ -歸約
  • 程序末尾, 沒有新的記號(hào)剩余, 對(duì)+ -進(jìn)行歸約

識(shí)別負(fù)數(shù)

  • 簡(jiǎn)單起見, 本程序總是使用浮點(diǎn)數(shù)作為基本計(jì)算單位
  • 把負(fù)號(hào)識(shí)別為浮點(diǎn)數(shù)的可選部分: 浮點(diǎn)數(shù) = -?d+(.d+)?

總體流程

  • 從os.Stdin讀入一行表達(dá)式字符串
  • 逐字符掃描記號(hào)流, 放入記號(hào)隊(duì)列
  • 逐記號(hào)出隊(duì), 置入計(jì)算棧
  • 判斷棧頂是否符合歸約條件, 是則進(jìn)行計(jì)算
  • 記號(hào)隊(duì)列空, 對(duì)計(jì)算棧進(jìn)行最終計(jì)算
  • 輸出結(jié)果

main.go

從os.Stdin循環(huán)讀入行

調(diào)用lexer.Parse獲得記號(hào)流

調(diào)用parser.Parse進(jìn)行計(jì)算

func main() {
    reader := bufio.NewReader(os.Stdin)
    for {
        fmt.Printf("=> ")
        arrBytes, _, err := reader.ReadLine()
        if err != nil {
            panic(err.Error())
        }
        line := strings.TrimSpace(string(arrBytes))
        expression := line
        tokens, e := lexer.Parse(expression)
        if e != nil {
            println(e.Error())
        } else {
            e,v := parser.Parse(tokens)
            if e != nil {
                println(e.Error())
            }
            fmt.Println(strconv.FormatFloat(v, 'f', 10, 64))
        }
    }
}

tokens/tokens.go

定義記號(hào)

package tokens
type TOKENS string
const IntLiteral TOKENS = "INT"
const DoubleLiteral TOKENS = "DBL"
const ADD TOKENS = "ADD"
const SUB TOKENS = "SUB"
const MUL TOKENS = "MUL"
const DIV TOKENS = "DIV"
const LB TOKENS = "LB"
const RB TOKENS = "RB"
const UNKNOWN TOKENS = "UNKNOWN"
type Token struct {
    Token TOKENS
    Value string
    Position int
}
func OfRune(t TOKENS, r rune, from int)  *Token {
    return &Token {
        Token: t,
        Value : string(r),
        Position: from,
    }
}
func OfString(t TOKENS, s string, from int)  *Token {
    return &Token {
        Token: t,
        Value : s,
        Position: from,
    }
}

states/states.go

定義lexer的狀態(tài)

type STATES int
const INITIAL STATES = 1
const INT_STATUS STATES = 11
const DOT_STATUS STATES = 12
const FRAG_STATUS STATES = 13

lexer/lexer.go

記號(hào)掃描

type tLexerState struct {
    state states.STATES
    tokens []*tokens.Token
    buffer []rune
    i0 int
    i1 int
    d0 int
    d1 int
}
func (me *tLexerState) AppendToken(t *tokens.Token) {
    me.tokens = append(me.tokens, t)
}
func (me *tLexerState) AppendChar(it rune) {
    me.buffer = append(me.buffer, it)
}
func (me *tLexerState) BufferSize() int {
    return len(me.buffer)
}
func (me *tLexerState) IntSize() int {
    return me.i1 - me.i0 + 1
}
func (me *tLexerState) FragSize() int {
    return me.d1 - me.d0 + 1
}
func Parse(line string) ([]*tokens.Token, error) {
    var state = &(tLexerState{
        state: states.INITIAL,
        tokens: make([]*tokens.Token, 0),
        buffer: make([]rune, 0),
        i0 : 0,
        i1 : 0,
        d0: 0,
        d1: 0,
    })
    for i, it := range line + "\n" {
        e := parseChar(state, i, it)
        if e != nil {
            return nil, e
        }
    }
    return state.tokens, nil
}
func parseChar(state *tLexerState, i int, it rune) error {
    var e error = nil
    switch state.state {
    case states.INITIAL:
        e = parseCharWhenInitial(state, i, it)
        break
    case states.INT_STATUS:
        e = parseCharWhenInt(state, i, it)
        break
    case states.DOT_STATUS:
        e = parseCharWhenDot(state, i, it)
        break
    case states.FRAG_STATUS:
        e = parseCharWhenFrag(state, i, it)
        break
    }
    return e
}
func parseCharWhenInitial(state *tLexerState, i int, it rune) error {
    if is_minus(it) || is_0_to_9(it) {
        state.state = states.INT_STATUS
        state.buffer = make([]rune, 0)
        state.buffer = append(state.buffer, it)
        state.i0 = i
        state.i1 = i
    } else if is_space(it){
        return nil
    } else if is_add(it) {
        state.AppendToken(tokens.OfRune(tokens.ADD, it, i))
    } else if is_sub(it) {
        state.AppendToken(tokens.OfRune(tokens.SUB, it, i))
    } else if is_mul(it) {
        state.AppendToken(tokens.OfRune(tokens.MUL, it, i))
    } else if is_div(it) {
        state.AppendToken(tokens.OfRune(tokens.DIV, it, i))
    } else if is_lb(it) {
        state.AppendToken(tokens.OfRune(tokens.LB, it, i))
    }  else if is_rb(it) {
        state.AppendToken(tokens.OfRune(tokens.RB, it, i))
    } else {
        return errors.New(fmt.Sprintf("parseCharWhenInitial, invalid char %c at %d", it, i))
    }
    return nil
}
func parseCharWhenInt(state *tLexerState, i int, it rune) error {
    if is_0_to_9(it) {
        if state.BufferSize() >= 10 {
            return errors.New(fmt.Sprintf("too large int number at %v", i))
        } else {
            state.AppendChar(it)
            state.i1 = i
        }
    } else if is_dot(it) {
        state.AppendChar(it)
        state.state = states.DOT_STATUS
    } else if is_space(it) {
        state.AppendToken(tokens.OfString(tokens.IntLiteral, string(state.buffer), state.i1))
        state.state = states.INITIAL
    } else if is_rb(it) {
        state.AppendToken(tokens.OfString(tokens.IntLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.RB, it, i))
        state.state = states.INITIAL
    }  else if is_add(it) {
        state.AppendToken(tokens.OfString(tokens.IntLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.ADD, it, i))
        state.state = states.INITIAL
    } else if is_sub(it) {
        state.AppendToken(tokens.OfString(tokens.IntLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.SUB, it, i))
        state.state = states.INITIAL
    } else if is_mul(it) {
        state.AppendToken(tokens.OfString(tokens.IntLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.MUL, it, i))
        state.state = states.INITIAL
    } else if is_div(it) {
        state.AppendToken(tokens.OfString(tokens.IntLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.DIV, it, i))
        state.state = states.INITIAL
    } else {
        return errors.New(fmt.Sprintf("parseCharWhenInt, invalid char %c at %d", it, i))
    }
    return nil
}
func parseCharWhenDot(state *tLexerState, i int, it rune) error {
    if is_0_to_9(it) {
        state.state = states.FRAG_STATUS
        state.AppendChar(it)
        state.d0 = i
        state.d1 = i
    } else {
        return errors.New(fmt.Sprintf("parseCharWhenDot, invalid char %c at %d", it, i))
    }
    return nil
}
func parseCharWhenFrag(state *tLexerState, i int, it rune) error {
    if is_0_to_9(it) {
        if state.FragSize() >= 10 {
            return errors.New(fmt.Sprintf("too many chars for a double value at %d", i))
        } else {
            state.AppendChar(it)
            state.d1 = i
        }
    } else if is_space(it) {
        state.AppendToken(tokens.OfString(tokens.DoubleLiteral, string(state.buffer), state.i1))
        state.state = states.INITIAL
    } else if is_add(it) {
        state.AppendToken(tokens.OfString(tokens.DoubleLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.ADD, it, i))
        state.state = states.INITIAL
    } else if is_sub(it) {
        state.AppendToken(tokens.OfString(tokens.DoubleLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.SUB, it, i))
        state.state = states.INITIAL
    } else if is_mul(it) {
        state.AppendToken(tokens.OfString(tokens.DoubleLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.MUL, it, i))
        state.state = states.INITIAL
    } else if is_div(it) {
        state.AppendToken(tokens.OfString(tokens.DoubleLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.DIV, it, i))
        state.state = states.INITIAL
    } else if is_rb(it) {
        state.AppendToken(tokens.OfString(tokens.DoubleLiteral, string(state.buffer), state.i1))
        state.AppendToken(tokens.OfRune(tokens.RB, it, i))
        state.state = states.INITIAL
    } else {
        return errors.New(fmt.Sprintf("parseCharWhenFrag, invalid char %c at %d", it, i))
    }
    return nil
}

parser/tStackNode.go

定義計(jì)算棧的一個(gè)節(jié)點(diǎn). 計(jì)算棧中有兩種節(jié)點(diǎn): 已歸約的值節(jié)點(diǎn), 和尚未計(jì)算的記號(hào)節(jié)點(diǎn)

type tStackNodeType int
const NODE_VALUE tStackNodeType = 1
const NODE_TOKEN tStackNodeType = 2
type tStackNode struct {
    flag tStackNodeType
    token *tokens.Token
    value float64
}
func newValueNode(value float64) *tStackNode {
    return &tStackNode{
        flag: NODE_VALUE,
        value: value,
        token: nil,
    }
}
func newTokenNode(token *tokens.Token) *tStackNode {
    return &tStackNode{
        flag: NODE_TOKEN,
        token: token,
        value: 0,
    }
}
func (me *tStackNode) getTokenType() tokens.TOKENS {
    switch me.flag {
    case NODE_VALUE:
        return tokens.DoubleLiteral
    case NODE_TOKEN:
        switch me.token.Token {
        case tokens.IntLiteral:
            fallthrough
        case tokens.DoubleLiteral:
            return tokens.DoubleLiteral
        default:
            return me.token.Token
        }
    }
    return tokens.UNKNOWN
}
func (me *tStackNode) getDoubleValue() float64 {
    switch me.flag {
    case NODE_VALUE:
        return me.value
    case NODE_TOKEN:
        switch me.token.Token {
        case tokens.IntLiteral:
            fallthrough
        case tokens.DoubleLiteral:
            v1,e1 := strconv.ParseFloat(me.token.Value, 64)
            if e1 != nil {
                panic(e1)
            }
            return v1
        }
    }
    panic("value not avaiable")
}

parser/parser.go

type tParser struct {
    tokens []*tokens.Token
    stack []*tStackNode
    total int
    position int
}
func newParser(tokens []*tokens.Token)  *tParser {
    return &tParser{
        tokens: tokens,
        stack: make([]*tStackNode, 0),
        total : len(tokens),
        position: -1,
    }
}
func (me *tParser) showStack() string {
    lst := make([]string, 0)
    for _,it := range me.stack {
        switch it.flag {
        case NODE_VALUE:
            lst = append(lst, strconv.FormatFloat(it.value, 'f', 10, 64))
            break
        case NODE_TOKEN:
            switch it.token.Token {
            case tokens.DoubleLiteral:
                fallthrough
            case tokens.IntLiteral:
                lst = append(lst, it.token.Value)
                break
            default:
                lst = append(lst, it.token.Value)
                break
            }
        }
    }
    return strings.Join(lst, " ")
}
func (me *tParser) moreToken() bool {
    return me.position < me.total - 1
}
func (me *tParser) nextToken() *tokens.Token {
    if !me.moreToken() {
        return nil
    }
    me.position++
    return me.currentToken()
}
func (me *tParser) currentToken() *tokens.Token {
    if me.position >= me.total {
        return nil
    }
    return me.tokens[me.position]
}
func (me *tParser) reduce() {
    sCurrentStack := ""
    var fnCheckState = func() {
        sStackState := me.showStack()
        if sStackState != sCurrentStack {
            sCurrentStack = sStackState
            fmt.Printf("stack => %s\n", sStackState)
        }
    }
    for {
        fnCheckState()
        if me.reduceMulOrDiv() {
            continue
        }
        if me.reduceBrackets() {
            continue
        }
        if !me.moreToken() {
            if me.reduceAddOrSub() {
                break
            }
        }
        fnCheckState()
        //time.Sleep(1*time.Second)
        break
    }
}
func (me *tParser) stackPop() *tStackNode {
    if me.isStackEmpty() {
        return nil
    }
    var iStackSize = len(me.stack)
    var last = me.stack[iStackSize - 1]
    me.stack = me.stack[:(iStackSize-1)]
    return last
}
func (me *tParser) stackPopN(n int) []*tStackNode {
    if me.isStackEmpty() {
        return nil
    }
    var iStackSize = len(me.stack)
    if iStackSize < n {
        return nil
    }
    var lstTailItems = me.stack[(iStackSize - n):]
    me.stack = me.stack[:(iStackSize-n)]
    return lstTailItems
}
func (me *tParser) stackTakeN(n int) []*tStackNode {
    if me.isStackEmpty() {
        return nil
    }
    var iStackSize = len(me.stack)
    if iStackSize < n {
        return nil
    }
    var lstHeadItems = me.stack[:n]
    me.stack = me.stack[n+1:]
    return lstHeadItems
}
func (me *tParser) stackPush(it *tStackNode) {
    me.stack = append(me.stack, it)
}
func (me *tParser) reduceMulOrDiv() bool {
    if me.isStackEmpty() {
        return false
    }
    if me.isStackRMatch(tokens.DoubleLiteral, tokens.MUL, tokens.DoubleLiteral) {
        var lstTailNodes = me.stackPopN(3)
        v1 := lstTailNodes[0].getDoubleValue()
        v2 := lstTailNodes[2].getDoubleValue()
        var v = v1*v2
        me.stackPush(newValueNode(v))
        return true
    } else if me.isStackRMatch(tokens.DoubleLiteral, tokens.DIV, tokens.DoubleLiteral) {
        var lstTailNodes = me.stackPopN(3)
        v1 := lstTailNodes[0].getDoubleValue()
        v2 := lstTailNodes[2].getDoubleValue()
        if v2 == 0 {
            panic(fmt.Sprintf("div by zero, %v / %v", v1, v2))
        }
        var v = v1/v2
        me.stackPush(newValueNode(v))
        return true
    }
    return false
}
func (me *tParser) reduceBrackets() bool {
    if me.isStackEmpty() {
        return false
    }
    if me.isStackRMatch(tokens.RB) {
        rb := me.stackPop()
        var v float64 = 0
        for {
            if me.isStackRMatch(tokens.LB, tokens.DoubleLiteral) {
                var lstTailNodes = me.stackPopN(2)
                v += lstTailNodes[1].getDoubleValue()
                me.stackPush(newValueNode(v))
                return true
            } else if me.isStackRMatch(tokens.ADD, tokens.DoubleLiteral) {
                var lstTailNodes = me.stackPopN(2)
                v1 := lstTailNodes[1].getDoubleValue()
                v = v + v1
            } else if me.isStackRMatch(tokens.SUB, tokens.DoubleLiteral) {
                var lstTailNodes = me.stackPopN(2)
                v1 := lstTailNodes[1].getDoubleValue()
                v = v - v1
            } else {
                panic(fmt.Sprintf("LB not found at %v", rb.token.Position))
            }
        }
    }
    return false
}
func (me *tParser) reduceAddOrSub() bool {
    var v float64 = 0
    for {
        if me.isStackEmpty() {
            break
        }
        if me.isStackRMatch(tokens.ADD, tokens.DoubleLiteral) {
            var lstTailNodes = me.stackPopN(2)
            v1 := lstTailNodes[1].getDoubleValue()
            v = v + v1
        } else if me.isStackRMatch(tokens.SUB, tokens.DoubleLiteral) {
            var lstTailNodes = me.stackPopN(2)
            v1 := lstTailNodes[1].getDoubleValue()
            v = v - v1
        } else if len(me.stack)==1 && me.isStackRMatch(tokens.DoubleLiteral) {
            it := me.stackPop()
            v += it.getDoubleValue()
            me.stackPush(newValueNode(v))
            return true
        } else {
            panic("invalid expression")
        }
    }
    return false
}
func (me *tParser) isStackEmpty() bool {
    return len(me.stack) == 0
}
func (me *tParser) isStackRMatch(args...tokens.TOKENS) bool {
    var iArgsSize = len(args)
    if iArgsSize <= 0 {
        return false
    }
    var iStackSize = len(me.stack)
    if iStackSize < iArgsSize {
        return false
    }
    for i,it := range args {
        var n = iStackSize - iArgsSize + i
        var xStackNode = me.stack[n]
        if it != xStackNode.getTokenType() {
            return false
        }
    }
    return true
}
func (me *tParser) isStackLMatch(args...tokens.TOKENS) bool {
    var iArgsSize = len(args)
    if iArgsSize <= 0 {
        return false
    }
    var iStackSize = len(me.stack)
    if iStackSize < iArgsSize {
        return false
    }
    for i,it := range args {
        var xStackNode = me.stack[i]
        if it != xStackNode.getTokenType() {
            return false
        }
    }
    return true
}
func (me *tParser) parse() (error, float64) {
    for {
        t := me.nextToken()
        if t == nil {
            break
        }
        me.stackPush(newTokenNode(t))
        me.reduce()
    }
    var iStackSize = len(me.stack)
    if iStackSize == 1 && me.stack[0].getTokenType() == tokens.DoubleLiteral {
        return nil, me.stack[0].getDoubleValue()
    }
    panic(fmt.Sprintf("failed parsing expression %s", me.showStack()))
}
func Parse(tokens []*tokens.Token) (error, float64) {
    parser := newParser(tokens)
    return parser.parse()
}

輸出

=&gt; 1+2*(3-4*(5/6+(7-8*9)))
stack => 1
stack => 1 +
stack => 1 + 2
stack => 1 + 2 *
stack => 1 + 2 * (
stack => 1 + 2 * ( 3
stack => 1 + 2 * ( 3 -
stack => 1 + 2 * ( 3 - 4
stack => 1 + 2 * ( 3 - 4 *
stack => 1 + 2 * ( 3 - 4 * (
stack => 1 + 2 * ( 3 - 4 * ( 5
stack => 1 + 2 * ( 3 - 4 * ( 5 /
stack => 1 + 2 * ( 3 - 4 * ( 5 / 6
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 +
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + (
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + ( 7
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + ( 7 -
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + ( 7 - 8
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + ( 7 - 8 *
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + ( 7 - 8 * 9
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + ( 7 - 72.0000000000
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + ( 7 - 72.0000000000 )
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + -65.0000000000
stack => 1 + 2 * ( 3 - 4 * ( 0.8333333333 + -65.0000000000 )
stack => 1 + 2 * ( 3 - 4 * -64.1666666667
stack => 1 + 2 * ( 3 - -256.6666666667
stack => 1 + 2 * ( 3 - -256.6666666667 )
stack => 1 + 2 * 259.6666666667
stack => 1 + 519.3333333333
520.3333333333
=>

以上就是golang 四則運(yùn)算計(jì)算器 yacc 歸約手寫實(shí)現(xiàn)的詳細(xì)內(nèi)容,更多關(guān)于golang四則運(yùn)算計(jì)算器yacc歸約的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Go語(yǔ)言集成開發(fā)環(huán)境之VS Code安裝使用

    Go語(yǔ)言集成開發(fā)環(huán)境之VS Code安裝使用

    VS Code是微軟開源的一款編輯器,插件系統(tǒng)十分的豐富,下面介紹如何用VS Code搭建go語(yǔ)言開發(fā)環(huán)境,需要的朋友可以參考下
    2021-10-10
  • Golang常用包使用介紹

    Golang常用包使用介紹

    標(biāo)準(zhǔn)的Go語(yǔ)言代碼庫(kù)中包含了大量的包,并且在安裝Go的時(shí)候多數(shù)會(huì)自動(dòng)安裝到系統(tǒng)中。我們可以在$GOROOT/src/pkg目錄中查看這些包。下面簡(jiǎn)單介紹一些我們開發(fā)中常用的包
    2022-09-09
  • 聊聊golang中多個(gè)defer的執(zhí)行順序

    聊聊golang中多個(gè)defer的執(zhí)行順序

    這篇文章主要介紹了golang中多個(gè)defer的執(zhí)行順序,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2021-05-05
  • 關(guān)于Golang變量初始化/類型推斷/短聲明的問題

    關(guān)于Golang變量初始化/類型推斷/短聲明的問題

    這篇文章主要介紹了關(guān)于Golang變量初始化/類型推斷/短聲明的問題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-02-02
  • golang通過反射設(shè)置結(jié)構(gòu)體變量的值

    golang通過反射設(shè)置結(jié)構(gòu)體變量的值

    這篇文章主要介紹了golang通過反射設(shè)置結(jié)構(gòu)體變量的值操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧
    2021-04-04
  • 深度剖析Golang中的數(shù)組,字符串和切片

    深度剖析Golang中的數(shù)組,字符串和切片

    Golang 是一種以簡(jiǎn)潔性、并發(fā)性和性能而著稱的編程語(yǔ)言。其重要特性之一是能夠處理數(shù)組、字符串和切片等數(shù)據(jù)類型。本篇文章將深入討論這些數(shù)據(jù)類型,并探討如何在代碼中使用它們
    2023-04-04
  • go內(nèi)存緩存如何new一個(gè)bigcache對(duì)象示例詳解

    go內(nèi)存緩存如何new一個(gè)bigcache對(duì)象示例詳解

    這篇文章主要為大家介紹了go內(nèi)存緩存如何new一個(gè)bigcache對(duì)象示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-09-09
  • Go 每日一庫(kù)之termtables的使用

    Go 每日一庫(kù)之termtables的使用

    本文主要介紹了Go 每日一庫(kù)之termtables的使用,termtables處理表格形式數(shù)據(jù)的輸出。是一個(gè)很小巧的工具庫(kù)。具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-07-07
  • Linux中Go環(huán)境配置和GoModule常用操作

    Linux中Go環(huán)境配置和GoModule常用操作

    這篇文章主要介紹了Linux中Go環(huán)境配置和GoModule,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-01-01
  • 使用GO操作MongoDB的方法

    使用GO操作MongoDB的方法

    這篇文章主要介紹了使用GO操作MongoDB,包括安裝MongoDB驅(qū)動(dòng)程序連接mongodb的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-05-05

最新評(píng)論