[go-nuts] How to build dynamic library with gollvm?

2021-06-29 Thread Peng Deng
Hi all I want to build a dynamic go library with gollvm. How could I do this? Thank you. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...

[go-nuts] How to compile a go program which uses cgo to llvm IR?

2021-06-09 Thread Peng Deng
Hi, I have the following program package main /* #include static void SayHello(const char* s) { puts(s); } */ import "C" func main() { C.SayHello(C.CString("Hello, World\n")) } I want to compile this program to LLVM IR with gollvm, the compilation instruction is as follows: llvm-goc

Re: [go-nuts] Why GO111MODULE=auto go get does not always work?

2021-02-24 Thread Peng Yu
ve commands? I made them up. > rsc.io/quote is an example of > repository to explain of how Go module works and not works if run without Go > module-aware. > > https://github.com/golang/go/issues/26367 So `GO111MODULE=auto go get ` should work for any other packages except rsc.io/qu

[go-nuts] Why GO111MODULE=auto go get does not always work?

2021-02-24 Thread Peng Yu
quote" -- Regards, Peng -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on

Re: [go-nuts] Why can net.Dial be very slow on a hostname defined in /etc/hosts?

2021-02-23 Thread Peng Yu
S to fix the performance problem. net.ResolveIPAddr("ip4", addr) -- Regards, Peng -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@

[go-nuts] ICMP in golang

2021-02-23 Thread Peng Yu
Hi, I see this ICMP example. But somebody says it is too old. What is the current way to ping a target in go? Thanks. https://gist.github.com/lmas/c13d1c9de3b2224f9c26435eb56e6ef3 -- Regards, Peng -- You received this message because you are subscribed to the Google Groups "golang

Re: [go-nuts] Why can net.Dial be very slow on a hostname defined in /etc/hosts?

2021-02-23 Thread Peng Yu
inted out, Go does not use the C library. > > > On Feb 23, 2021, at 7:57 AM, Peng Yu wrote: > > > > This does not answer the question why net.Dial can not be made with > > the same behavior as ping on MacOSX. If the C library behaves > > differently on MacOSX and Li

Re: [go-nuts] Why can net.Dial be very slow on a hostname defined in /etc/hosts?

2021-02-23 Thread Peng Yu
wrote: > It looks like the Go runtime implements its own DNS client on *unix > platforms including OSX. > >> On Feb 22, 2021, at 11:40 PM, Peng Yu wrote: >> >> I don’t understand why ping does not have the same problem. Ping is not >> based on C library? >>

Re: [go-nuts] Why can net.Dial be very slow on a hostname defined in /etc/hosts?

2021-02-22 Thread Peng Yu
I don’t understand why ping does not have the same problem. Ping is not based on C library? On Mon, Feb 22, 2021 at 11:20 PM Ian Lance Taylor wrote: > On Mon, Feb 22, 2021 at 9:11 PM Peng Yu wrote: > > > > I tried 1.16. > > > > $ go version > > go versio

Re: [go-nuts] Why can net.Dial be very slow on a hostname defined in /etc/hosts?

2021-02-22 Thread Peng Yu
/etc/hosts? On 2/22/21, Ian Lance Taylor wrote: > On Mon, Feb 22, 2021 at 12:22 PM Peng Yu wrote: >> >> I run the following go program using net.Dial(). Depending on whether >> I specify a local hostname (defined in /etc/hosts) or an IP. I get >> very differen

[go-nuts] Why can net.Dial be very slow on a hostname defined in /etc/hosts?

2021-02-22 Thread Peng Yu
:30 after $ cat main.go package main import ( "net" "log" "os" ) func main() { dialAddr := os.Args[1] log.Println("before") _, err := net.Dial("tcp", dialAddr) log.Println("after") if err != nil { log.Fatalln(err) } }

Re: [go-nuts] SSL socket listener

2020-06-04 Thread 'Wesley Peng' via golang-nuts
t;,"server.key",nil) if err != nil { log.Fatal("ListenAndServe: ",err) } } -- Wesley Peng wesleyp...@aol.com -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this gro

[go-nuts] SSL socket listener

2020-06-03 Thread 'Wesley Peng' via golang-nuts
Hello, How do I program with SSL to make a server listen on specific port which accepts SSL transfer only? Is there any guide for this since I have no experience on SSL socket programming. Thanks. Wesley Peng wesleyp...@aol.com -- You received this message because you are subscribed to the

[go-nuts] Is there a library for validating gmail's Variants

2020-04-30 Thread Walter Peng
Hello community, We are running a small website which allow users registration with their email. Many users use gmail's variants to sign up the site, as we know, foo...@gmail.com is equivalent to below similar: foo...@googlemail.com foob...@googlemail.com foo@gmail.com foobar+...@gmail.com

[go-nuts] Is this AMQP 0.9.1 library updated?

2020-04-28 Thread 'Wesley Peng' via golang-nuts
Hello, I tried to access RabbitMQ using this AMQP library:https://github.com/streadway/amqp I am not sure if this library get updated following the recent RMQ version.Please suggest, thanks. Wesley Peng wesleyp...@aol.com -- You received this message because you are subscribed to the Google

[go-nuts] How to write unit test for init()?

2018-11-26 Thread Vast Peng
The code below: package component import "os" type BaseicConfig struct{ } func init() { configDir := os.Getenv(constant.ProjectRootEnv) if configDir == "" { // run here. log.Panic(constant.InvalidEnvVariables) } configPath := filepath.Join(configDir, constant.ConfigName) if _, err := t

[go-nuts] [help wanted] golang build failed on linux console tty but build ok on gui terminal

2018-05-23 Thread Zhou Peng
GOARCH="amd64" GOBIN="" GOCACHE="/home/ctriple/.cache/go-build" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/ctriple/go" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" CC="gcc" CXX="g++" CGO_ENABLED="1" CGO_CFLAGS

[go-nuts] Best batch processing example in go

2018-01-23 Thread Peng Yu
this problem? Thanks. P.S., here is one webpage, but it does not allow multiple workers. https://blog.drkaka.com/batch-get-from-golangs-buffered-channel-9638573f0c6e -- Regards, Peng -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To u

[go-nuts] What is go concurrency based on?

2018-01-22 Thread Peng Yu
Hi, I'd like to know what go concurrency is based on. For example, nodejs is based on libev, making nodejs more efficient than using multithreading to handle concurrency. What is go based on to make go concurrency more effecient than multithreading? -- Regards, Peng -- You received this me

Re: [go-nuts] Is there something similar to cmp in python?

2018-01-21 Thread Peng Yu
This only applies to string but not other types like int. On Sun, Jan 21, 2018 at 8:18 AM Arie van Wingerden wrote: > https://golang.org/src/strings/compare.go > > 2018-01-21 14:42 GMT+01:00 Peng Yu : > >> Hi, cmp() in python can return three values -1, 0, 1. Is there a >

[go-nuts] Is there something similar to cmp in python?

2018-01-21 Thread Peng Yu
Hi, cmp() in python can return three values -1, 0, 1. Is there a comparison function in golang that also return three values? Thanks. https://docs.python.org/2/library/functions.html#cmp -- Regards, Peng -- You received this message because you are subscribed to the Google Groups "g

[go-nuts] Can go files be nested in package?

2018-01-20 Thread Peng Yu
package mypkg func Double(x int) int { return Add(x, y) } -- Regards, Peng -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...

Re: [go-nuts] How to import local go files?

2018-01-20 Thread Peng Yu
the term "exported" in the language specification. > > On Sat, Jan 20, 2018, 23:30 Peng Yu wrote: >> >> Why is only Add allowed? Where is this documented? > > -- > > -j -- Regards, Peng -- You received this message because you are subscribed to the G

Re: [go-nuts] How to import local go files?

2018-01-20 Thread Peng Yu
Why is only Add allowed? Where is this documented? Thanks. On Sat, Jan 20, 2018 at 2:49 PM, Jan Mercl <0xj...@gmail.com> wrote: > > On Sat, Jan 20, 2018 at 9:29 PM Peng Yu wrote: > > s/add/Add/g > > > -- > > -j -- Regards, Peng -- You received this message

[go-nuts] How to import local go files?

2018-01-20 Thread Peng Yu
{ var value mypackage.Export value.DoMagic() fmt.Printf("%s", value) fmt.Print(mypackage.add(1, 2)) } $ go build main.go # command-line-arguments ./main.go:12:13: cannot refer to unexported name mypackage.add ./main.go:12:13: undefined: mypackage.add -- Regards, Peng -- Y

[go-nuts] Is there something like peekable in python?

2018-01-20 Thread Peng Yu
Hi, the concept of peekable iterator from python is very convenient. Is there something similar in golang. https://github.com/erikrose/more-itertools/blob/master/more_itertools/more.py#L134 -- Regards, Peng -- You received this message because you are subscribed to the Google Groups "g

Re: [go-nuts] How to bufio.Write with a length specified?

2018-01-18 Thread Peng Yu
you want to write a length shorter than the slice, make the slice > shorter. No, seriously... > > n, err := f.Write(d[:2]) > > On Thu, 2018-01-18 at 17:04 -0600, Peng Yu wrote: >> Hi, >> >> The following example shows how to write a byte slice to a buffer. >>

[go-nuts] How to bufio.Write with a length specified?

2018-01-18 Thread Peng Yu
noexpandtab tabstop=2: package main import ( "os" "bufio" "fmt" ) func main() { f := bufio.NewWriter(os.Stdout) d := []byte{'s', 'o', 'm', 'e', '\n'} n, err := f.Write(d) f.Flush() fmt.Pri

[go-nuts] Re: In which case does compiler not able to get the address of a value?

2017-07-07 Thread Peng
Thanks Dave & TL. Regards, Peng 在 2017年7月7日星期五 UTC+8上午9:44:55,Dave Cheney写道: > > This is a really interesting corner case of the syntactic sugar of the > language. > > The first piece of sugar is that methods are just functions with a > predefined first parameter, or to s

[go-nuts] Re: In which case does compiler not able to get the address of a value?

2017-07-07 Thread Peng
sable structs - elements of addressable arrays - elements of any slices (whether the slices are addressable or not) - pointer dereference operations Regards, Peng 在 2017年7月7日星期五 UTC+8上午9:44:55,Dave Cheney写道: > > This is a really interesting corner case of the syntactic sugar of the > langu

[go-nuts] In which case does compiler not able to get the address of a value?

2017-07-06 Thread Peng
Hi, In the chapter of "Method set" from "Go in Action", there is a description as below "This shows that it’s not always possible to get the address of a value.", the question is in which case does compiler not able to get the address of a value and why, thanks. 01 // Sample program to show ho

[go-nuts] Download all dependencies using go get ./...

2016-12-18 Thread Peng Wang
I have a project that using golang.org/x/crypto/ssh, when I try to build it, i usually do a go get ./... command(since it's easy to remember for every project and shorter than go get golang.org/x/crypto/ssh), but then it reports cannot find package "golang.org/x/net/context/ctxhttp". It seems it

[go-nuts] Re: How many bytes binary.Write write before an error?

2016-12-16 Thread Peng Wang
OK, now I actually get it. Just use a CounterWriter and return bytes num it receives. Such writer already exists in the std lib? 在 2016年12月16日星期五 UTC+8下午2:10:41,P Q写道: > > 2016년 12월 16일 금요일 오전 11시 5분 53초 UTC+9, Peng Wang 님의 말: > Actually I don't really care about that, just don&#x

[go-nuts] Re: How many bytes binary.Write write before an error?

2016-12-15 Thread Peng Wang
OK, this point of view seems fair enough, I can take that. But won't a normal user would expect that // FooBuffer is some kind of buffer that fails randomly w := FooBuffer(conn) n ,err := m.WriteTo(w) // if binary.Write returns error, n will be 0, buf actual bytes may not be zero. // n == w.Buffe

[go-nuts] Re: How many bytes binary.Write write before an error?

2016-12-15 Thread Peng Wang
Then I should deal with the encoding of all the envelope fields. This envelope seems to be simple, but i got a more complicated one in the real dev works. 在 2016年12月16日星期五 UTC+8上午10:44:27,ma...@influxdb.com写道: > > > > On Thursday, December 15, 2016 at 6:05:53 PM UTC-8, Pen

[go-nuts] Failed to cross compile go program

2016-10-09 Thread Peng Gao
When I run this command GOOS=linux GOARCH=amd64 go build I got this error # crypto/sha256 asm: invalid instruction: 10572 (/Users/mike/workplace/go/src/crypto/sha256/sha256block_amd64.s:733) VPSHUFD $250, Y7, Y2 asm: invalid instruction: 11157 (/Users/mike/workplace/go/src/crypto/sha256/sha

[go-nuts] Re: not available from my location when I run git mail to submit a patch.

2016-09-28 Thread Peng Gao
Use a proxy fix it. On Wednesday, September 28, 2016 at 11:25:31 PM UTC+8, Peng Gao wrote: > > I just make a path and want to push it, I got this error > > git mail > fatal: remote error: Access Denied (not available from your location) > (running: git push -q origin HEAD:refs

[go-nuts] not available from my location when I run git mail to submit a patch.

2016-09-28 Thread Peng Gao
I just make a path and want to push it, I got this error git mail fatal: remote error: Access Denied (not available from your location) (running: git push -q origin HEAD:refs/for/master) git-codereview: exit status 128 what's the reason? -- You received this message because you are subscribed

[go-nuts] Re: Calling a Go function from asm ("fatal error: missing stackmap")

2016-09-19 Thread Peng Gao
On Tuesday, September 20, 2016 at 11:00:34 AM UTC+8, Peng Gao wrote: > > BTW in your test file, you can directly append your bytes slice. > b1 = append(b1, vs...) > and slicesEqual is redundant, bytes.Equal does test the length of two > arguments > I mix up cap and len, just i

[go-nuts] Re: Calling a Go function from asm ("fatal error: missing stackmap")

2016-09-19 Thread Peng Gao
BTW in your test file, you can directly append your bytes slice. b1 = append(b1, vs...) and slicesEqual is redundant, bytes.Equal does test the length of two arguments. On Tuesday, September 20, 2016 at 6:56:55 AM UTC+8, Caleb Spare wrote: > > I'm trying to call a Go function from asm and I'm ha

[go-nuts] How runtime.newobjcet is optimized in map access?

2016-08-26 Thread Peng Gao
I am doing a bench for my map-based cache. the get implementation is the same // Get an item from the cache. Returns the item or nil, and a bool indicating // whether the key was found. func (c *cache) Get(k string) (interface{}, bool) { c.mu.RLock() // "Inlining" of get and Expired item, found :