golang

栏目: Go · 发布时间: 7年前

内容简介:1.brew安装的golang,需要设置GOPATH2.beego api 生成命令generatedoc报错需要设置goroot的PATH

安装

1.brew安装的golang,需要设置GOPATH

export GOROOT=/usr/local/opt/go/libexec

2.beego api 生成命令generatedoc报错

需要设置goroot的PATH

export  GOROOT=/usr/local/opt/go/libexec
export  GOPATH=~/mycode/golang
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"

mysql

1.连接并插入数据

package main

import (
    "fmt"
    "database/sql"
    _ "github.com/go-sql-driver/mysql"
)

func main() {
    fmt.Println("Go MySQL Tutorial")
    
    // Open up our database connection.
    // I've set up a database on my local machine using phpmyadmin.
    // The database is called testDb
    db, err := sql.Open("mysql", "root:123456@tcp(192.168.56.112:12345)/api")
    
    // if there is an error opening the connection, handle it
    if err != nil {
        panic(err.Error())
    }
    
    // defer the close till after the main function has finished
    // executing 
    defer db.Close()
    
    // perform a db.Query insert 
    insert, err := db.Query("INSERT INTO test VALUES ( 5, 'good' )")
    
    // if there is an error inserting, handle it
    if err != nil {
        panic(err.Error())
    }
    // be careful deferring Queries if you are using transactions
    defer insert.Close()
    
    
}

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

新媒体运营

新媒体运营

勾俊伟 / 人民邮电出版社 / 2018-5-1 / 39.80

本书全面介绍了新媒体运营以及新媒体运营各模块的具体内容。 第 1章重点介绍新媒体运营的基本概念,其中包括运营的定义、发展历史及专业术语; 第 2章重点介绍新媒体运营的职业发展,通过企业需求反推能力清单,引导读者全面了解新媒体运营的岗位及相关要求; 第3章重点介绍用户运营的方法与策略,包括描述用户画像、搭建用户体系、吸引精准用户及提升用户活跃度等具体技巧; 第4章重点介绍产品......一起来看看 《新媒体运营》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试