[go-nuts] Re: any discourse-like forum in Go?

2018-01-31 Thread peterGo
Sebastien, Go中国技术社区 - golang (https://gocn.io/) says it is Powered By WeCenter 3.1.9 (https://github.com/wecenter). WeCenter 问答系统的环境需求 (https://github.com/wecenter/wecenter/blob/master/README.md) 可用的 www 服务器,如 Apache、IIS、nginx, 推荐使用性能高效的 Apache 或 nginx. PHP 5.2.2 及以上 MySQL 5.0 及以上

[go-nuts] Re: ioutil.ReadAll()

2018-02-13 Thread peterGo
Patrik, Someone pulled the floppy disk out of the FDD. Someone waved a magnet over the HDD, Cosmic rays hit the SSD, Someone pulled Eternet cable out of its socket. And so on. How about a simple bug? "ioutil.ReadAll: invalid argument": https://play.golang.org/p/r8mfn5KvaE8 Peter On Tuesday,

[go-nuts] Re: How to reuse go fix tool code

2018-03-16 Thread peterGo
Anuj Agrawal, Exporting an API carries a commitment to maintain and support that API. go fix was a special-purpose command, that was useful before the Go1 compatibility guarantee. I can see no reason to export a go fix API. Peter On Thursday, March 15, 2018 at 6:20:47 AM UTC-4, Anuj Agrawal wr

[go-nuts] Re: where would one find "go tool tour" with fedora-installed pkgs?

2018-04-11 Thread peterGo
Robert, On Ubuntu, I ran, $ go get -v -u golang.org/x/tour/... $ gotour Please file a complaint about the missing instructions: https://github.com/golang/go/issues. Peter On Wednesday, April 11, 2018 at 1:46:51 PM UTC-4, Robert P. J. Day wrote: > > > more sophomoric questions -- following a

[go-nuts] Re: [NEWBIE] what means importing a file versus a directory?

2018-04-11 Thread peterGo
Robert, First, read, The Go Programming Language Specification https://golang.org/ref/spec Packages https://golang.org/ref/spec#Packages Peter On Wednesday, April 11, 2018 at 9:22:04 AM UTC-4, Robert P. J. Day wrote: > > > total beginner question here, but the docs seem vague or > inconsis

[go-nuts] Re: Keep Vendor folder on library Repository is Bad or Good practice.

2018-08-09 Thread peterGo
Tong Sun "I've never seen [the Author delete the library] happen before." It happened recently. Take a look at jteeuwen/go-bindata: Hard fork of jteeuwen/go-bindata because it disappeared, Peter On Wednesday, August 8, 2018 at 10:01:32 AM UTC-4, Tong Sun wrote: > > I've never seen that happen

[go-nuts] Re: golang + wasm three times slower than javascript?

2018-08-10 Thread peterGo
Kim, These are not useful results. Exponential recursive algorithms are known to be very expensive. Use an iterative algorithm. See Fibonacci Numbers and Binomial Coefficients: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.137.752&rep=rep1&type=pdf For example, $ go version go ver

Re: [go-nuts] Ternary ... again

2018-08-15 Thread peterGo
Mark, "Adding just a few things like these to the language might help with adoption and that in itself is a worthwhile goal. I suspect many developers that love Go aren’t currently using it on real projects. Getting more developers to consider Go makes that more likely." There are several fall

Re: [go-nuts] Unsafe Pointer rules

2018-08-22 Thread peterGo
On Tuesday, August 21, 2018 at 7:08:43 PM UTC-4, Carl Mastrangelo wrote: > > > The reason I am interested in this is (and please don't judge too early) > is I'm toying around with implementing some atomic primitives. In > particular, I would like to play around with with the cmpxchg16b > instru

Re: [go-nuts] Unsafe Pointer rules

2018-08-22 Thread peterGo
On Tuesday, August 21, 2018 at 7:08:43 PM UTC-4, Carl Mastrangelo wrote: > > The answer must be more nuanced than that, because it is possible to take > a nil pointer and construct an unsafe.Pointer from it. > > The reason I am interested in this is (and please don't judge too early) > is I'm t

[go-nuts] Re: Unexpected behavior of %+02d in Sprintf() and friends

2018-08-28 Thread peterGo
Eric, "Width is specified by an optional decimal number immediately preceding the verb. If absent, the width is whatever is necessary to represent the value. " https://golang.org/pkg/fmt/ Width is two. Peter On Tuesday, August 28, 2018 at 12:09:26 PM UTC-4, Eric Raymond wrote: > > Under Go 1

[go-nuts] Re: Unexpected behavior of %+02d in Sprintf() and friends

2018-08-28 Thread peterGo
t2-YJfQvEo Widths three and two. Peter On Tuesday, August 28, 2018 at 4:49:02 PM UTC-4, peterGo wrote: > > Eric, > > "Width is specified by an optional decimal number immediately preceding > the verb. If absent, the width is whatever is necessary to represent the > value

[go-nuts] Re: Regarding string immutablity

2018-08-28 Thread peterGo
Jay, A Go string is represented by a struct. type stringStruct struct { str unsafe.Pointer len int } Assigning a new value to a string variable is a struct assignment that does not immediately destroy the underlying value of the original string. Peter On Tuesday, August 28, 2018 at 10

[go-nuts] Re: More trouble with date formatting

2018-08-29 Thread peterGo
Eric, The fmt package verb %v is the value in a default format, typically the String method for the type. func (Time) String func (t Time) String() string String returns the time formatted using the format string "2006-01-02 15:04:05.9 -0700 MST" The returned string is meant for de

Re: [go-nuts] More trouble with date formatting

2018-08-29 Thread peterGo
Paul, The Go Playground sandbox has a few peculiarities, for example for date and time. Results may not match those found in ordinary use. Peter On Wednesday, August 29, 2018 at 9:24:32 AM UTC-4, Borman, Paul wrote: > > I put your program onto the playground: > https://play.golang.org/p/L0xJgw

[go-nuts] Re: parse date/time with comma before millis

2018-08-30 Thread peterGo
Adam, In Go, it's usual to hide any ugliness in a function. For example, https://play.golang.org/p/cfj8NntLHAO Peter On Thursday, August 30, 2018 at 7:21:33 PM UTC-4, skirmish wrote: > > In example code here; https://play.golang.org/p/4P2nH_KE8uu > > I'm trying to parse a date time string of th

[go-nuts] Re: Taking possible EOF as input

2018-09-04 Thread peterGo
Hunter, Your main.go file is 171 lines of dense code. If you reduced your issue to a small, working piece of code, people would be more likely help you. You say "bufio.Scan() doesn't return io.EOF." Why? $ go doc bufio.scanner type Scanner struct { } Scanning stops unrecoverably at EOF, th

[go-nuts] Re: Taking possible EOF as input

2018-09-04 Thread peterGo
oking for would need to check for the > SIG.KILL/EOF on input. Now whether or not i shoudlgo and alter the > bufio.Scanner to return io.EOF as an Err is a different thing. But that > would be a smidge excessive for just 1 minor functionality. > On Tuesday, 4 September 201

[go-nuts] Re: Can't print GO2 draft documents with firefox 61.0.1 (64 bits) Ubuntu

2018-09-05 Thread peterGo
Christophe, Print the draft documents from Firefox Quantum 61.0.1 (64-bit) for Mozilla Firefox for Ubuntu canonical - 1.0. For example, print: Error Handling — Draft Design https://go.googlesource.com/proposal/+/master/design/go2draft-error-handling.md Firefox Menu -> Print -> Check Simplify

Re: [go-nuts] Re: Can't print GO2 draft documents with firefox 61.0.1 (64 bits) Ubuntu

2018-09-05 Thread peterGo
Sam, What happenned when you followed the instructions I gave to Christophe? Peter On Wednesday, September 5, 2018 at 6:34:00 PM UTC-4, Sam Whited wrote: > > On Wed, Sep 5, 2018, at 15:04, peterGo wrote: > > Print the draft documents from Firefox Quantum 61.0.1 (64-bit) fo

[go-nuts] Re: Can't print GO2 draft documents with firefox 61.0.1 (64 bits) Ubuntu

2018-09-06 Thread peterGo
Christophe, I gave you precise, tested instructions on how to print from your current Firefox browser. Did you follow the instructions? Peter On Thursday, September 6, 2018 at 3:29:56 AM UTC-4, Christophe Meessen wrote: > > Thank you for the suggestions peterGo, but that is my current b

[go-nuts] Re: Windows Build Problem

2018-11-06 Thread peterGo
Henry, MinGW and TDM-GCC both work for installing Go from source on Windows 10 64-bit. Here is MinGW: # Windows: Microsoft Windows [Version 10.0.17134.345] # gcc: C:\Users\peter>gcc --version gcc (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.2.0 # Go1.4: C:\Users\peter\Go1.4\bin>go

[go-nuts] Re: How to make the first character in a string lowercase?

2019-01-07 Thread peterGo
Nikolai, "What is the easiest way to make a string "LikeThis" --> "likeThis"?" Te easiest is not always the best. The code should be correct and reasonably efficient. For example, func firstToLower(s string) string { if len(s) > 0 { r, size := utf8.DecodeRuneInString(s) if r

[go-nuts] Re: Github independent issue tracker

2019-01-08 Thread peterGo
Jan Mercl, "There's also that OpenID thing." OpenID may not be a good idea. Stack Exchange: Support for OpenID ended on July 25, 2018: https://meta.stackexchange.com/questions/307647/support-for-openid-ended-on-july-25-2018 Peter On Tuesday, January 8, 2019 at 4:25:39 AM UTC-5, Jan Mercl wrot

[go-nuts] Re: Arrays

2019-01-14 Thread peterGo
John, Here is a simple proof-of-concept implementation. Playground: https://play.golang.org/p/Hd0dmazXI5v Output: 11 12 13 14 21 22 23 24 31 32 33 34 XX 12 13 14 21 XX 23 24 31 32 XX 34 Peter On Monday, January 14, 2019 at 12:47:50 AM UTC-5, John wrote: > > Dear Gophers, > >

[go-nuts] Re: Golang 1.11 Windows Support

2019-01-14 Thread peterGo
Discontinuation of support for Go and Windows XP and Vista has the usual meaning. If you encounter a problem, neither the Go team nor Microsoft will help. You are on your own. Peter On Monday, January 14, 2019 at 1:25:07 PM UTC-5, Subramanian Sridharan wrote: > > Hello Gophers! > > I read that

[go-nuts] Re: Can I say a int64 type variable takes 8 bytes of memory and a int32 type variable takes 4 bytes of memory?

2019-01-15 Thread peterGo
"Can I say a int64 type variable takes 8 bytes of memory and a int32 type variable takes 4 bytes of memory?" You can answer your question by reading the specification. The Go Programming Language Specification https://golang.org/ref/spec Numeric types https://golang.org/ref/spec#Numeric_types

[go-nuts] Re: When would you use single quotes?

2019-02-07 Thread peterGo
Jamie, This is a question about Unicode: The Unicode Consortium: http://unicode.org/ The Unicode Standard: http://www.unicode.org/standard/standard.html Unicode Frequently Asked Questions: UTF-8, UTF-16, UTF-32 & BOM: http://www.unicode.org/faq/utf_bom.html Briefly, a Unicode code point is 24

[go-nuts] Re: Documention of a blog entry out of date

2019-02-11 Thread peterGo
Victor, If you look at the source code, you may find that the blog inadvertently switched decode and encode. See encode.go. Reporting issues: If you spot bugs, mistakes, or inconsistencies in the Go project's code or documentation, please let us know by filing a ticket on our issue tracker. ht

[go-nuts] Re: Persistence of value, or Safely close what you expected

2019-03-13 Thread peterGo
Andrey, Your program has a data race. The results are undefined. Data Race Detector https://golang.org/doc/articles/race_detector.html $ go run -race racer.go == WARNING: DATA RACE Write at 0x0050dfa0 by goroutine 6: main.niller() /home/peter/gopath/src/racer.go:6 +0

[go-nuts] Re: When slice decide to expand cap?

2019-04-11 Thread peterGo
jianfeng ye, Post text not images! Experiments that are not reproducible have no value. You posted low-contrast images of your experiments and results. Reproducing your results using OCR and/or typing is too hard and too error prone. My experiments are: $ go version go version devel +a5032bc

[go-nuts] Re: Language Specification nit under Constant declarations

2019-04-16 Thread peterGo
Marvin Renich, "I would interpret the phrase," "I think the phrase," and "I prefer" are your personal interpretation, thoughts, and preference. Go prefers standard interpretations: US words, spelling, grammar, and dictionaries. For example, Merriam-Webster Definition of preceding : existing, co

[go-nuts] Re: methods on C types

2019-04-18 Thread peterGo
Cgo translates C types into equivalent unexported Go types. https://golang.org/cmd/cgo/ Peter On Thursday, April 18, 2019 at 2:25:11 AM UTC-4, dja...@gmail.com wrote: > > Hi, > where is documented that methods can be created on C types ? > > This works with go1.12.4, linux: > https://play.golang.

[go-nuts] Re: Experience using Go for a student projet

2017-07-30 Thread peterGo
Juliusz, Thank you. That's very interesting. Code should be correct, maintainable, robust, readable, and reasonably efficient. Readablity is a prerequisite for the other properties. I glanced at babelweb2 (https://github.com/Vivena/babelweb2/). A code review would be useful. For example, from

Re: [go-nuts] Go goes crazy on math.Sin()

2017-07-30 Thread peterGo
Ian, Is this just a variation of https://github.com/golang/go/issues/6794 ? Peter On Sunday, July 30, 2017 at 10:22:54 PM UTC-4, Ian Lance Taylor wrote: > > On Sun, Jul 30, 2017 at 10:40 AM, > > wrote: > > > > I just ran this code on my pc: > > > > package main > > > > import ( > >"

[go-nuts] Re: How to optimize as with -O2 from Gcc? (50x speedup)

2017-08-04 Thread peterGo
Dorival Pedroso, PowP has a lot of code. PowG is simpler and it is modestly slower for small values of n and much faster for larger values of n. func PowG(x float64, n uint32) float64 { y := 1.0 for i := n; i > 0; i >>= 1 { if i&1 == 1 { y *= x } x *=

[go-nuts] Re: Generics are overrated.

2017-08-05 Thread peterGo
Lucio, "It took Dijkstra quite some effort to accept the concept of "interrupts" (quotation anyone?), but eventually he went with it." E.W. Dijkstra Archive: My recollections of operating system design (EWD1303) https://www.cs.utexas.edu/users/EWD/transcriptions/EWD13xx/EWD1303.html "The third

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-09 Thread peterGo
Package testing https://golang.org/pkg/testing/ Benchmarks The benchmark function must run the target code b.N times. During benchmark execution, b.N is adjusted until the benchmark function lasts long enough to be timed reliably. The first thing to do is to reduce the program to the simplest

[go-nuts] Re: Trying to understand Go benchmarking

2017-08-10 Thread peterGo
Egon, Obviously I ran the race detector. No races were detected. Therefore, since it wasn't germane, I omitted it from the posted results. Here's my results. $ go test -run=! -bench=. -v -cpu=4 -race total_test.go goos: linux goarch: amd64 BenchmarkTotal/Count-4 5000

[go-nuts] Re: A small question on os.FileInfo

2017-08-13 Thread peterGo
Timothy, struct stat { /* ... */ off_t st_size;/* total size, in bytes */ /* ... */ }; off_t is a signed integer. File offsets can be negative. Peter On Sunday, August 13, 2017 at 8:27:21 PM UTC-4, Timothy Raymond wrote: > > I was working with filepath.Walk(), and I noticed

[go-nuts] Re: A small question on os.FileInfo

2017-08-13 Thread peterGo
; On Monday, 14 August 2017 11:57:30 UTC+10, peterGo wrote: >> >> Timothy, >> >> struct stat { >> /* ... */ >> off_t st_size;/* total size, in bytes */ >> /* ... */ >> }; >> >> off_t is a signed integer. >> >&

[go-nuts] Re: recent golang toolchain build issue

2017-08-20 Thread peterGo
Peter, Yes, It's really, really annoying. See https://github.com/golang/go/issues/21452. Temporarily, I'm running $ rm -f ../pkg/linux_amd64_shared/runtime/cgo.a && ./all.bash Peter On Sunday, August 20, 2017 at 12:57:43 AM UTC-4, Peter Arnt wrote: > > Greetings, > > I have been tracking the

[go-nuts] Re: when to switch a goroutine to be executed

2017-08-20 Thread peterGo
Yp Xie, The Go scheduler is cooperative: https://en.wikipedia.org/wiki/Cooperative_multitasking You are using one processor: runtime.GOMAXPROCS(1). Force the main goroutine to yield: runtime.Gosched(). For example, https://play.golang.org/p/7HnogkMOOo 0: main 1: main 0: not main 2: main 1: n

[go-nuts] Re: Best way to truncate a ridiculously long string in GO

2017-08-22 Thread peterGo
A benchmark; https://play.golang.org/p/oUyeldDG5Q $ cat strslice_test.go package main import ( "strings" "testing" ) var ( s = strings.Repeat("a very, very long string", 4096) prefix string ) func BenchmarkNil(b *testing.B) { for i := 0; i < b.N; i++ { prefix =

[go-nuts] Re: Best way to truncate a ridiculously long string in GO

2017-08-22 Thread peterGo
nchmarkCopy-4 500030.8 ns/op 3 > B/op 1 allocs/op > BenchmarkLoop-4 500029.3 ns/op 3 > B/op 1 allocs/op > > Cheers > Val > > On Tuesday, August 22, 2017 at 1:01:36 PM UTC+2, peterGo w

[go-nuts] Re: Golang 1.9 failing with excelize (simple case works under 1.8.3)

2017-08-26 Thread peterGo
In Go, always check for errors. For example, mysheet := xlsx.GetSheetName(1) https://godoc.org/github.com/360EntSecGroup-Skylar/excelize#File.GetSheetName func (*File) GetSheetName func (f *File) GetSheetName(index int) string GetSheetName provides function to get sheet name of XLSX by giv

[go-nuts] Re: Golang 1.9 failing with excelize (simple case works under 1.8.3)

2017-08-26 Thread peterGo
:13 AM UTC-4, peterGo wrote: > > In Go, always check for errors. For example, > > mysheet := xlsx.GetSheetName(1) > > > https://godoc.org/github.com/360EntSecGroup-Skylar/excelize#File.GetSheetName > > func (*File) GetSheetName > > func (f *File) GetSheetName(i

[go-nuts] Re: Correct checkout branch go1.9 in 'Installing Go from source'

2017-08-29 Thread peterGo
Will Zhou, Yes. The objective is to be on the current point release. For example. // Clone current point release: go1.9.1 $ git clone https://go.googlesource.com/go $ cd go/src $ git checkout release-branch.go1.9 $ ./make.bash $ go version go version go1.9.1 linux/amd64 // ... // Update to cur

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-31 Thread peterGo
Michael, Your read times look slow to me. I used bytconv instead of strconv. bytconv: read 100 98.517584ms sort 100 481.994354ms strconv: read 100 174.720883ms sort 100 479.437831ms bytconv is the missing Go standard library package. bytconv is the byte input analog of string i

Re: [go-nuts] Why isn't golang input and output is buffered?

2017-08-31 Thread peterGo
ring conversions. , BenchmarkAtoiBytconv-4 5000 30.4 ns/op0 B/op0 allocs/op BenchmarkAtoiStrconv-4 2000102 ns/op 8 B/op1 allocs/op https://play.golang.org/p/oSQ8RZeGL7 Peter On Thursday, August 31, 2017 at 12:24:20 PM UTC-4, peterGo wrote: > > Michae

[go-nuts] Re: golang preempt schedule how work ?

2017-09-05 Thread peterGo
For example, package main import ( "runtime" "time" ) var sum1 int64 func add1() { for i := 0; i < 1; i++ { runtime.Gosched() for j := 0; j < 1; j++ { sum1++ } } } func bar() { for { add1() } } func main() { runti

Re: [go-nuts] Re: Copying slice over itself

2017-09-07 Thread peterGo
Rob, "Two slices sharing an array will, however, share their last element. Here is a better test, but this is pretty magical stuff: https://play.golang.org/p/SZgpCh9D-l"; a := []int{0, 1, 2, 3, 4, 5, 6, 7} s := a[1:3:5] https://play.golang.org/p/Q

[go-nuts] Re: Copying slice over itself

2017-09-07 Thread peterGo
Deepak Jois, Consider this case: The Go Programming Language Specification https://golang.org/ref/spec Slice expressions https://golang.org/ref/spec#Slice_expressions Full slice expressions For an array, pointer to array, or slice a (but not a string), the primary expression a[low : high

[go-nuts] Re: try to avoid additional memory allocations

2017-11-09 Thread peterGo
Vasiliy, For portability, when you initialize cfg.WorkDir, clean it: cfg.WorkDir = filepath.Clean(cfg.WorkDir) You can reduce the allocations from 5 to 1. However, optimization can lead to obscurity. For example, $ go test oid_test.go -bench=. BenchmarkVasiliy-4 200700 ns/op88

[go-nuts] Re: warning: "std" matched no packages (hello world works)

2017-11-11 Thread peterGo
If you had removed all remnants of gccgo and followed these installation instructions Getting Started https://golang.org/doc/install I would have expected to see something like this: $ go version go version go1.9.2 linux/amd64 $ go env GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTO

[go-nuts] Re: How to convert from []byte to []uint32?

2017-11-13 Thread peterGo
Christian, Your specialized convertCharToInt32 function, which returns []uint32, is slow in comparison to a more general HexToUint function. BenchmarkHexToUint32-8 200088.9 ns/op 16 B/op2 allocs/op BenchmarkCharToInt32-8300 438 ns/op 96 B/op 22 allocs/op Playgrou

[go-nuts] Re: How to convert from []byte to []uint32?

2017-11-13 Thread peterGo
olang.org/p/Jxkf2Vheml > > On Monday, November 13, 2017 at 3:57:57 PM UTC-8, peterGo wrote: >> >> Christian, >> >> Your specialized convertCharToInt32 function, which returns []uint32, is >> slow in comparison to a more general HexToUint function. >> >

[go-nuts] Re: Use and redeclare same variable in block

2018-01-28 Thread peterGo
"I intuitively thought only j is declared in if block and i will be the same as outer one." The compiler knows nothing about your intuition! It follows The Go Programming Language Specification https://golang.org/ref/spec Short variable declarations https://golang.org/ref/spec#Short_variable_d

[go-nuts] Re: Web access to golang-dev is down

2019-05-07 Thread peterGo
Liam, "Web access to golang-dev is down" is too vague. Please be more precise. For example, my recent experience: For the past few days, browsing to golang-dev without logging on, I get an error: https://groups.google.com/forum/#!forum/golang-dev An error (#401) occurred while communicating w

[go-nuts] Re: Stack based slice usage and unsafe

2019-05-26 Thread peterGo
Sergey Kamardin, Your code is invalid. A uintptr variable is an integer, not a pointer. type SliceHeader: https://golang.org/pkg/reflect/#SliceHeader SliceHeader is the runtime representation of a slice. It cannot be used safely or portably and its representation may change in a later release.

[go-nuts] Re: go 1.13 changes

2019-07-28 Thread peterGo
rob solomon, Go 1.13 Release Notes: https://tip.golang.org/doc/go1.13 peter On Sunday, July 28, 2019 at 12:02:14 PM UTC-4, rob wrote: > > I recently saw a description including rationale and historical > references regarding the new features being added to version 1.13. > > Now I cannot find

[go-nuts] Re: Problems with windows installation v1.31.1

2019-10-09 Thread peterGo
Longeri Carlos, Go 1.13 Release Notes https://golang.org/doc/go1.13 godoc and go doc https://golang.org/doc/go1.13#godoc The godoc webserver is no longer included in the main binary distribution. To run the godoc webserver locally, manually install it first: go get golang.org/x/tools/cmd/godo

[go-nuts] Re: What is the difference between fmt.Print and rand.Intn functions here?

2016-08-31 Thread peterGo
TL, Radically different parameters: func Intn(n int ) int func Println(a ...interface{}) (n int , err error ) Peter On Wednesday, August 31,

[go-nuts] Re: Surprising benchmark allocations

2016-09-02 Thread peterGo
Francis, First, fix any bugs. For example, "The benchmark function must run the target code b.N times." https://golang.org/pkg/testing/ Therefore, keyVals := make([]string, b.N*10) // ... for _, key := range keyVals { setOne(s, key) } should be keyVals := make([]string, b.N) // ...

Re: [go-nuts] Re: Surprising benchmark allocations

2016-09-02 Thread peterGo
Francis, And, of course, keyVals := make([]string, b.N*10) // ... for _, key := range keyVals { setTwo(s, key) } should be keyVals := make([]string, b.N) // ... for _, key := range keyVals { setTwo(s, key) } or s /b.N*10/b.N/g Peter On Fri, Sep 2, 2016 at 4:38 PM, peterGo

[go-nuts] Re: How the main func started?

2016-09-17 Thread peterGo
dc0d, It's implementation dependendent. Be explicit. For example, pass a flag argument, *//go:generate go run main.go -gogenerate* Peter On Saturday, September 17, 2016 at 9:28:16 AM UTC-4, dc0d wrote: > > How to find out if the *main* function is started by executing the > compiled binary or

[go-nuts] Re: golang memory allocation

2016-10-06 Thread peterGo
You are reporting all the allocations made in a BenchmarkFmt function which includes allocations made in the fmt.Println function. See https://golang.org/src/fmt/print.go. Peter On Thursday, October 6, 2016 at 12:01:16 AM UTC-4, 刘桂祥 wrote: > > > > package main > > > import ( > "fmt" > _

Re: [go-nuts] weird?

2016-12-10 Thread peterGo
TL, If you want to be a language lawyer then you must cite the law (The Go Language Specification) to support your argument. For example, perhaps something like this: >From the law: Method expressions Consider a struct type T with two methods, Mv, whose receiver is of type T, and Mp, whose r

Re: [go-nuts] weird?

2016-12-10 Thread peterGo
ing it's weird is not enough. Peter On Saturday, December 10, 2016 at 5:37:25 AM UTC-5, T L wrote: > > > > On Saturday, December 10, 2016 at 6:20:00 PM UTC+8, peterGo wrote: >> >> TL, >> >> If you want to be a language lawyer then you must cite the law (Th

[go-nuts] Re: memclr optimazation does worse?

2016-12-14 Thread peterGo
TL, For your results, it's a small increase of 1.9%. For my results, it's a small decrease of −2.03%. $ go version go version devel +232991e Wed Dec 14 05:51:01 2016 + linux/amd64 $ go test -bench=. BenchmarkMemclr_100-4 2000 115 ns/op BenchmarkLoop_100-4

[go-nuts] Re: memclr optimazation does worse?

2016-12-14 Thread peterGo
tl36.282s $ Memclr is 17.15% faster than Loop for a very large slice. Peter On Wednesday, December 14, 2016 at 10:38:43 AM UTC-5, peterGo wrote: > > TL, > > For your results, it's a small increase of 1.9%. > > For my results, it's a small decrease of −2.03%. > > $

[go-nuts] Re: install go compiler without sudo right

2016-12-23 Thread peterGo
Bill, The OP said: "I tried to install go1.4 then use it to install latest go." Then you asked the OP: "Do you want to use Go version 1.4 specifically for some reason?" Peter On Thursday, December 22, 2016 at 12:57:40 PM UTC-5, bill.h...@gmail.com wrote: > > Do you want to use Go version 1.4

[go-nuts] Raspberry Pi : PIXEL for PC and Mac: Go

2016-12-23 Thread peterGo
PIXEL for PC and Mac https://www.raspberrypi.org/blog/pixel-pc-mac/ PIXEL for PC and Mac, a new Linux distribution from Raspberry Pi, doesn't come with Go installed. As a test, I installed Go on a PC from source and ran all tests successfully. pi@raspberrypi:~/go/src $ ./all.bash <> ALL TESTS

[go-nuts] Re: install go compiler without sudo right

2016-12-26 Thread peterGo
You tell us that you tried some stuff and it didn't work. The first step in debugging is to provide a simple, reproducible example. For example, here's a statement of a problem, a recipe for the Go boostrap compiler step, and a log of the output and the results. It's reproducible. Sudo is only r

[go-nuts] Re: Correct naming of Go !

2016-12-27 Thread peterGo
Ken, Go is formally defined by its specification. The Go Programming Language Specification https://golang.org/ref/spec The name of the language is Go. For example, The Go Programming Language http://www.gopl.io/ Peter On Tuesday, December 27, 2016 at 11:23:20 AM UTC-5, Ken Nakagama wrote: >

[go-nuts] Re: convert a given time in one Timezone to other TimeZone

2016-08-10 Thread peterGo
LV, "Each Time has associated with it a Location, consulted when computing the presentation form of the time, such as in the Format, Hour, and Year methods. The methods Local, UTC, and In return a Time with a specific location. Changing the location in this way changes only the presentation; i

[go-nuts] Re: Unexpected Behaviour of goroutine

2017-02-12 Thread peterGo
Srivathsan, Go Frequently Asked Questions (FAQ) What happens with closures running as goroutines? https://golang.org/doc/faq#closures_and_goroutines Peter On Sunday, February 12, 2017 at 5:51:14 AM UTC-5, Srivathsan Madhavan wrote: > > Hi all, > > I still consider myself a newbie to Golang hence

[go-nuts] Re: Go 1.8 : cmd/go : test timed out after 3m0s

2017-02-17 Thread peterGo
Peter, You can get a complete Go installation by running ./make.bash. Running ./all.bash adds a lot of testing for Go compiler and standard library developers. Peter On Friday, February 17, 2017 at 6:28:22 AM UTC-5, Peter Kleiweg wrote: > > Installing Go 1.8 with: > > git pull > git ch

[go-nuts] Re: Building Go from Source / Managing my ${GOROOT}

2017-02-19 Thread peterGo
Ayan, It's not idiomatic because you are setting and using GOROOT. Leave that to the compiler. For example, with no GOROOT, $ cd $HOME $ git clone https://go.googlesource.com/go $ cd go/src $ ./make.bash Peter On Saturday, February 18, 2017 at 5:51:09 PM UTC-5, Ayan George wrote: > > I'm some

Re: go test -race much slower in 1.8 (was Re: [go-nuts] Go 1.8 is released)

2017-02-21 Thread peterGo
Will, "it looks like the plan is to fix this in Go 1.9 rather than 1.8.x, is that the case? " What makes you think that? https://github.com/golang/go/issues/19151: Milestone Go1.8.1 https://github.com/golang/go/issues/19133: Milestone Go1.8.1 Peter On Tuesday, February 21, 2017 at 5:41:25 AM

[go-nuts] Re: Code review/Advice - reading and editing a CSV

2017-02-24 Thread peterGo
Robbie, It's hard to understand what you are doing. The header says that there is no grade and sg is not where you say it is. Why are you using a channel? Why are you limiting the size of your input by reading the entire file into memory? And so on. My best guess is that you want to do somethi

[go-nuts] Re: Code review/Advice - reading and editing a CSV

2017-02-24 Thread peterGo
Robbie, Fixed a typo: https://play.golang.org/p/JbKGJMw4r3 Peter On Friday, February 24, 2017 at 12:48:44 PM UTC-5, peterGo wrote: > > Robbie, > > It's hard to understand what you are doing. > > The header says that there is no grade and sg is not where you say it is.

[go-nuts] Re: Code review/Advice - reading and editing a CSV

2017-02-24 Thread peterGo
Robbie, Fixed some typos: https://play.golang.org/p/GGjoeOYfRN Peter On Friday, February 24, 2017 at 12:48:44 PM UTC-5, peterGo wrote: > > Robbie, > > It's hard to understand what you are doing. > > The header says that there is no grade and sg is not where you say it is.

[go-nuts] Re: Is uint(v) when v is minus because a huge number supposed behavior?

2017-02-25 Thread peterGo
Felix, The Go Programming Language Specification https://golang.org/ref/spec Conversions https://golang.org/ref/spec#Conversions When converting between integer types, if the value is a signed integer, it is sign extended to implicit infinite precision; otherwise it is zero extended. It is the

[go-nuts] Re: correct way to convert wchar_t* to string ?

2017-02-27 Thread peterGo
Mark, For example, Go Playground: https://play.golang.org/p/dv48PLY-CD Peter On Monday, February 27, 2017 at 11:05:32 AM UTC-5, Mark wrote: > > Ooops just realised that I didn't enforce the max chars limit. Here's > another version: > > func CwcharToString(p uintptr, maxchars int) string { >

[go-nuts] Re: correct way to convert wchar_t* to string ?

2017-02-27 Thread peterGo
Mark, Fixed typos and made minor improvements. Go Playground: https://play.golang.org/p/cbQL8-72s5 Peter On Monday, February 27, 2017 at 11:05:32 AM UTC-5, Mark wrote: > > Ooops just realised that I didn't enforce the max chars limit. Here's > another version: > > func CwcharToString(p uintptr

[go-nuts] Re: units disappear from duration at 0.

2017-02-28 Thread peterGo
wrote: > > This should be good enough to justify what is a zero duration. > > 在 2016年1月21日星期四 UTC+8下午12:57:26,peterGo写道: >> >> Simon, >> >> By design, the Go answer to problems like this is often a simple >> function. For example, >> >>

[go-nuts] Re: do {} for x, why or why not?

2017-03-03 Thread peterGo
milo, How is your loop different from this? for { // if condition { break } } Peter On Friday, March 3, 2017 at 5:00:41 PM UTC-5, milo.chr...@gmail.com wrote: > > I rather like Go's loops, they are simple and easy to remember, and the > problem so m

[go-nuts] Re: fixed precision formatting of floating point

2017-03-12 Thread peterGo
simon, The IEEE Standard for Floating-Point Arithmetic (IEEE 754) defines sets of binary and decimal floating-point data, which consist of finite numbers (including signed zeros and subnormal numbers), infinities, and special "not a number" values (NaNs). Signed Zero: https://en.wikipedia.org/

Re: [go-nuts] uint type safety in go

2017-03-16 Thread peterGo
Michael, "Now, for personal opinion, I would share a tremendous frustration that programmers often don't think at all about these issues and thereby allow their thinking to be shallow. My clearest example is code like "k=i+j" or "k = i*j" both of which are common." Are you shocked—shocked—to f

[go-nuts] Re: a some naive question, but I can't find the answer from Go spec. Is it possible compiler adds paddings between array elements sometimes?

2017-03-20 Thread peterGo
TL, https://golang.org/ref/spec#Size_and_alignment_guarantees For eample, some strcts. Peter On Monday, March 20, 2017 at 11:23:02 AM UTC-4, T L wrote: > > Or if the first element in an array is 64bit aligned and the size of array > elements is 8N bytes, > is it for sure that all elements in t

[go-nuts] Re: a some naive question, but I can't find the answer from Go spec. Is it possible compiler adds paddings between array elements sometimes?

2017-03-20 Thread peterGo
s/strcts/structs/ On Monday, March 20, 2017 at 1:24:06 PM UTC-4, peterGo wrote: > > TL, > > https://golang.org/ref/spec#Size_and_alignment_guarantees > > For eample, some strcts. > > Peter > > On Monday, March 20, 2017 at 11:23:02 AM UTC-4, T L wrote: >> >&

[go-nuts] Re: a some naive question, but I can't find the answer from Go spec. Is it possible compiler adds paddings between array elements sometimes?

2017-03-20 Thread peterGo
T L, For example: https://play.golang.org/p/BSwB8jQwBY Peter On Monday, March 20, 2017 at 1:24:46 PM UTC-4, peterGo wrote: > > s/strcts/structs/ > > On Monday, March 20, 2017 at 1:24:06 PM UTC-4, peterGo wrote: >> >> TL, >> >> https://golang.org/ref/spec#Siz

[go-nuts] Re: Puzzled by a profiling result around allocations

2017-03-21 Thread peterGo
Harry, To be meaningful, benchmarks must be reproducible. You use some file with 10 million lines and 2.4 gigabytes. grepin.go (https://play.golang.org/p/YGRAJ6dEVn) is a program that generates known input data. Your programs had variations other than Bytes() and Text(). grepbytes.go (https:/

[go-nuts] Re: Puzzled by a profiling result around allocations

2017-03-21 Thread peterGo
s/greptext.go (https://play.golang.org/p/XzW6IBueyy)/greptext.go ( https://play.golang.org/p/-C9bVEJ2QP))/ On Tuesday, March 21, 2017 at 2:40:29 PM UTC-4, peterGo wrote: > > Harry, > > To be meaningful, benchmarks must be reproducible. > > You use some file with 10 mil

[go-nuts] Re: Why does these two code behave differently? (swap two elements in a slice)

2017-03-22 Thread peterGo
Cholerae Hu, The assignment proceeds in two phases. First, the operands of index expressions and pointer indirections (including implicit pointer indirections in selectors

[go-nuts] Re: Best practice for Method Receivers

2017-03-24 Thread peterGo
Frequently Asked Questions (FAQ) Should I define methods on values or pointers? https://golang.org/doc/faq#methods_on_values_or_pointers If some of the methods of the type must have pointer receivers, the rest should too, so the method set is consistent regardless of how the type is used. Peter

[go-nuts] Re: Open Snappy File?

2017-03-26 Thread peterGo
Tomi, Read the Go snappy package documentation: https://godoc.org/github.com/golang/snappy Write the code: https://play.golang.org/p/vNQ2xgDtDC Peter On Sunday, March 26, 2017 at 8:53:42 AM UTC-4, Tomi Häsä wrote: > > Are there beginner instructions on how to open snz files with Go? > > I did

Re: [go-nuts] Only build go binary from source

2017-03-26 Thread peterGo
Filip, ~ $ cd go/src ~/go/src $ ./make.bash --no-clean # Building Go bootstrap tool. cmd/dist # Building Go toolchain using /home/peter/go1.4. bootstrap/cmd/internal/dwarf bootstrap/cmd/internal/src bootstrap/cmd/internal/sys bootstrap/cmd/asm/internal/flags bootstrap/cmd/internal/bio boo

[go-nuts] Re: Random Number Genaration - Golang -- Error/Bug

2017-04-04 Thread peterGo
Mukund, If you suspect a bug in the compiler or the standard library, compile annd run the program using the latest version or, even better, tip so that you include all known bug fixes. I couldn't reproduce your error at Go tip: $ go version go version devel +bebfd4b Tue Apr 4 06:26:11 2017 +0

  1   2   3   >