linux下,google的go語(yǔ)言安裝起來(lái)很方便,用起來(lái)也很爽,幾行代碼就可以實(shí)現(xiàn)很強(qiáng)大的功能。
現(xiàn)在的問(wèn)題是我想在windows下玩……
其實(shí)windows下也不麻煩,具體見(jiàn)下文。
package main
import "fmt"
func main() {
fmt.Println("Test")
}
'''
File : compileGo.py
Author : Mike
E-Mail : Mike_Zhang@live.com
'''
import os
srcSuffix = '.go'
dstSuffix = '.exe'
cmdCompile = "8g"
cmdLink = "8l"
fList = []
for dirPath,dirNames,fileNames in os.walk('.'):
for file in fileNames:
name,extension = os.path.splitext(file)
if extension == srcSuffix :
fList.append(name)
tmpName = name + '.8' # temp file
strCompile = '%s -o %s %s ' % (cmdCompile,tmpName,file)
print strCompile
os.popen(strCompile) # compile
strLink = '%s -o %s %s' % (cmdLink,name+dstSuffix,tmpName)
print strLink
os.popen(strLink) # link
os.remove(tmpName) # remove temp file
break # only search the current directory