使用指令
1.objcopy
objcopy -S -g apps
2.strip
strip apps
2016年9月30日 星期五
GO Web cgi server
package main
import(
"net/http/cgi"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
handler := new(cgi.Handler)
handler.Path = "/root/goweb/" + r.URL.Path
// handler.Dir = "/root/goweb/"
log.Println(handler.Path)
log.Println(handler.Args)
handler.ServeHTTP(w, r)
})
log.Fatal(http.ListenAndServe(":8080",nil))
}
import(
"net/http/cgi"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
handler := new(cgi.Handler)
handler.Path = "/root/goweb/" + r.URL.Path
// handler.Dir = "/root/goweb/"
log.Println(handler.Path)
log.Println(handler.Args)
handler.ServeHTTP(w, r)
})
log.Fatal(http.ListenAndServe(":8080",nil))
}
GO Web cgi server (直接執行 go )
package main
import(
"net/http/cgi"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
handler := new(cgi.Handler)
handler.Path = "/usr/local/bin/go"
script := "/root/goweb/" + r.URL.Path
log.Println(handler.Path)
handler.Dir = "/root/goweb/"
args := []string{"run", script}
handler.Args = append(handler.Args, args...)
handler.Env = append(handler.Env, "GOPATH=/root/goweb")
handler.Env = append(handler.Env, "GOROOT=/usr/local/go")
log.Println(handler.Args)
handler.ServeHTTP(w, r)
})
log.Fatal(http.ListenAndServe(":8080",nil))
}
import(
"net/http/cgi"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
handler := new(cgi.Handler)
handler.Path = "/usr/local/bin/go"
script := "/root/goweb/" + r.URL.Path
log.Println(handler.Path)
handler.Dir = "/root/goweb/"
args := []string{"run", script}
handler.Args = append(handler.Args, args...)
handler.Env = append(handler.Env, "GOPATH=/root/goweb")
handler.Env = append(handler.Env, "GOROOT=/usr/local/go")
log.Println(handler.Args)
handler.ServeHTTP(w, r)
})
log.Fatal(http.ListenAndServe(":8080",nil))
}
GOLANG CGI範例
package main
import (
"net/http/cgi"
"net/http"
"fmt"
)
func errorResponse(code int, msg string) {
fmt.Printf("Status:%d %s\r\n", code, msg)
fmt.Printf("Content-Type: text/plain\r\n")
fmt.Printf("\r\n")
fmt.Printf("%s\r\n", msg)
}
func main() {
var req *http.Request
var err error
req, err = cgi.Request()
if err != nil {
errorResponse(500, "cannot get cgi request" + err.Error())
return
}
fmt.Printf("Content-Type: text/html\r\n")
fmt.Printf("\r\n")
fmt.Printf("<pre>\n")
import (
"net/http/cgi"
"net/http"
"fmt"
)
func errorResponse(code int, msg string) {
fmt.Printf("Status:%d %s\r\n", code, msg)
fmt.Printf("Content-Type: text/plain\r\n")
fmt.Printf("\r\n")
fmt.Printf("%s\r\n", msg)
}
func main() {
var req *http.Request
var err error
req, err = cgi.Request()
if err != nil {
errorResponse(500, "cannot get cgi request" + err.Error())
return
}
fmt.Printf("Content-Type: text/html\r\n")
fmt.Printf("\r\n")
fmt.Printf("<pre>\n")
fmt.Printf("req=%v\r\n", req) }
2016年9月29日 星期四
2016年9月20日 星期二
GIT :error: src refspec master does not match any
錯誤的原因:目錄中沒有文件,空目錄是不能提交上去
新增文件就可以
touch README
git add README
git commit -m 'first commit'
git push origin master
新增文件就可以
touch README
git add README
git commit -m 'first commit'
git push origin master
2016年9月19日 星期一
GOLANG MySQL 查詢範例
安裝 mySQL 介面
go get github.com/go-sql-driver/mysql
程式範例
package main
import (
_ "github.com/go-sql-driver/mysql"
"database/sql"
"fmt"
)
func main() {
db, err := sql.Open("mysql", "user:password@tcp(192.168.1.1:3306)/dbname?charset=utf8&allowOldPasswords=1")
checkErr(err)
rows, err := db.Query("SELECT `load` FROM a limit 10")
checkErr(err)
for rows.Next() {
var load int
err = rows.Scan(&load)
checkErr(err)
fmt.Println(load)
}
db.Close()
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}
go get github.com/go-sql-driver/mysql
程式範例
package main
import (
_ "github.com/go-sql-driver/mysql"
"database/sql"
"fmt"
)
func main() {
db, err := sql.Open("mysql", "user:password@tcp(192.168.1.1:3306)/dbname?charset=utf8&allowOldPasswords=1")
checkErr(err)
rows, err := db.Query("SELECT `load` FROM a limit 10")
checkErr(err)
for rows.Next() {
var load int
err = rows.Scan(&load)
checkErr(err)
fmt.Println(load)
}
db.Close()
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}
2016年9月2日 星期五
CentOS6 Xwindow 支援中文設定
yum -y groupinstall "chinese support"
修改 /etc/sysconfig/i18n
LANG="en_US.UTF-8" --> LANG="zh_TW.UTF-8"
gcin 輸入法
http://mirrors.sohu.com/fedora-epel/6/x86_64/gcin-1.5.1-1.el6.x86_64.rpm
修改 /etc/sysconfig/i18n
LANG="en_US.UTF-8" --> LANG="zh_TW.UTF-8"
gcin 輸入法
http://mirrors.sohu.com/fedora-epel/6/x86_64/gcin-1.5.1-1.el6.x86_64.rpm
VPS + CentOS6 + XWindow + XRDP
yum -y upgrade
yum -y install xorg-x11-fonts-Type1 xorg-x11-fonts-truetype
yum -y groupinstall "X Window System" "Desktop"
rpm -Uvh http://fedora.ip-connect.vn.ua/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install xrdp
yum -y install firefox tigervnc tigervnc-server tigervnc-server-module
chkconfig haldaemon --levels 2345 off
chkconfig xrdp --levels 345 on
service xrdp start
echo "gnome-wm" > /root/.vnc/xstartup
yum -y install xorg-x11-fonts-Type1 xorg-x11-fonts-truetype
yum -y groupinstall "X Window System" "Desktop"
rpm -Uvh http://fedora.ip-connect.vn.ua/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install xrdp
yum -y install firefox tigervnc tigervnc-server tigervnc-server-module
chkconfig haldaemon --levels 2345 off
chkconfig xrdp --levels 345 on
service xrdp start
echo "gnome-wm" > /root/.vnc/xstartup
訂閱:
文章 (Atom)