Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Go1 两行代码编译生成超大EXE
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Liigo Zhuang  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 2:58 am
From: Liigo Zhuang <com.li...@gmail.com>
Date: Fri, 30 Mar 2012 14:58:16 +0800
Local: Fri, Mar 30 2012 2:58 am
Subject: Go1 两行代码编译生成超大EXE

以下代码用到Go1标准库fmt和expvar,仅两行代码,结果编译生成的EXE超大,达 3.2 MB。我的系统是 Windows 7, x86。
按说,如果仅仅输出 fmt.Println("Hello world"),EXE应该在 1.1 MB 是比较正常的表现。

编译方法:
go build expvar.go

--------------------------------------------------------
package main

import (
"fmt"
"expvar"
)

func main() {
fmt.Println("Hello, Go1. This is liigo.")
expvar.Do(func(kv expvar.KeyValue){ fmt.Printf("\n%s=%s\n",kv.Key,kv.Value)

})
}

--------------------------------------------------------

--
by *Liigo*, http://blog.csdn.net/liigo/
Google+  https://plus.google.com/105597640837742873343/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
minux  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 3:02 am
From: minux <minux...@gmail.com>
Date: Fri, 30 Mar 2012 15:02:21 +0800
Local: Fri, Mar 30 2012 3:02 am
Subject: Re: [gocn:3433] Go1 两行代码编译生成超大EXE

2012/3/30 Liigo Zhuang <com.li...@gmail.com>

问题是你用了expvar,于是你间接引用了超级多的包。
$ go list -f {{.Deps}} expvar
[bufio bytes compress/flate compress/gzip crypto crypto/aes crypto/cipher
crypto/des crypto/dsa crypto/elliptic crypto/hmac crypto/md5 crypto/rand
crypto/rc4 crypto/rsa crypto/sha1 crypto/subtle crypto/tls crypto/x509
crypto/x509/pkix encoding/asn1 encoding/base64 encoding/binary
encoding/json encoding/pem errors fmt hash hash/crc32 io io/ioutil log math
math/big math/rand mime mime/multipart net net/http net/textproto net/url
os path path/filepath reflect runtime runtime/cgo runtime/debug sort
strconv strings sync sync/atomic syscall time unicode unicode/utf16
unicode/utf8 unsafe]
看看fmt引用了啥:
$ go list -f {{.Deps}} fmt
[errors io math os reflect runtime strconv sync sync/atomic syscall time
unicode/utf8 unsafe]

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Liigo Zhuang  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 3:24 am
From: Liigo Zhuang <com.li...@gmail.com>
Date: Fri, 30 Mar 2012 15:24:09 +0800
Local: Fri, Mar 30 2012 3:24 am
Subject: Re: [gocn:3434] Go1 两行代码编译生成超大EXE

哦,明白了。想不到啊。

在 2012年3月30日 下午3:02,minux <minux...@gmail.com>写道:

--
by *Liigo*, http://blog.csdn.net/liigo/
Google+  https://plus.google.com/105597640837742873343/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andy W. Song  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 3:37 am
From: "Andy W. Song" <wson...@gmail.com>
Date: Fri, 30 Mar 2012 15:37:41 +0800
Local: Fri, Mar 30 2012 3:37 am
Subject: Re: [gocn:3435] Go1 两行代码编译生成超大EXE

话说这个expvar到底是做嘛用的?

2012/3/30 Liigo Zhuang <com.li...@gmail.com>

--
---------------------------------------------------------------
有志者,事竟成,破釜沉舟,百二秦关终属楚
苦心人,天不负,卧薪尝胆,三千越甲可吞吴

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fango  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 4:13 am
From: fango <fan.how...@gmail.com>
Date: Fri, 30 Mar 2012 16:13:11 +0800
Local: Fri, Mar 30 2012 4:13 am
Subject: Re: [gocn:3436] Go1 两行代码编译生成超大EXE
应该是Export Variables的缩写。举例是运行godoc,然后 http://localhost:6060/debug/vars。

fango

On Fri, Mar 30, 2012 at 3:37 PM, Andy W. Song <wson...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fango  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 4:18 am
From: fango <fan.how...@gmail.com>
Date: Fri, 30 Mar 2012 16:18:36 +0800
Local: Fri, Mar 30 2012 4:18 am
Subject: Re: [gocn:3436] Go1 两行代码编译生成超大EXE
我是想说expose variables.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
fango  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 4:29 am
From: fango <fan.how...@gmail.com>
Date: Fri, 30 Mar 2012 16:29:14 +0800
Local: Fri, Mar 30 2012 4:29 am
Subject: Re: [gocn:3436] Go1 两行代码编译生成超大EXE
补充:go  list -f {{.Deps | len}} net/http 可以看到实际是这个http很大,使用了56个导入,而expvar只多了两个。

fango


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Liigo Zhuang  
View profile   Translate to Translated (View Original)
 More options Mar 30 2012, 4:51 am
From: Liigo Zhuang <com.li...@gmail.com>
Date: Fri, 30 Mar 2012 16:51:57 +0800
Local: Fri, Mar 30 2012 4:51 am
Subject: Re: [gocn:3436] Go1 两行代码编译生成超大EXE

顶楼的代码在我电脑上会输出以下内容,大致包含了内存使用和命令行信息:
其他还在摸索中……
--------------------------------------------------------------------------- -------------------------------
memstats={"Alloc":286552,"TotalAlloc":298352,"Sys":2621440, ... <<very
long>> ... }

cmdline=["D:\\Users\\liigo\\AppData\\Local\\Temp\\go-build209051666\\comman d-line-arguments\\_obj\\a.out.exe"]

--------------------------------------------------------------------------- -------------------------------

在 2012年3月30日 下午3:37,Andy W. Song <wson...@gmail.com>写道:

--
by *Liigo*, http://blog.csdn.net/liigo/
Google+  https://plus.google.com/105597640837742873343/

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »