[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;

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

[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

[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, 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

[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: 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

[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: 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 { >

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: 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) // ...

[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" >

[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

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

[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
36.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 version >

[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

[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

[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: 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

[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: 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.

[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

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

[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/re

[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

[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: >> &g

[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

[go-nuts] Re: os.Getwd() on windows changes drive letter casing

2017-04-17 Thread peterGo
Andreas, Why do you care? Naming Files, Paths, and Namespaces https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx "Do not assume case sensitivity. For example, consider the names OSCAR, Oscar, and oscar to be the same." Peter On Monday, April 17, 2017 at 3:06:50 PM UTC,

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-15 Thread peterGo
刘桂祥, Size and alignment guarantees https://golang.org/ref/spec#Size_and_alignment_guarantees A struct or array type has size zero if it contains no fields (or elements, respectively) that have a size greater than zero. Two distinct zero-size variables may have the same address in memory. You

Re: [go-nuts] go build -gcflags '-N -l' don't work

2017-04-15 Thread peterGo
rday, April 15, 2017 at 12:14:48 PM UTC-4, peterGo wrote: > > 刘桂祥, > > Size and alignment guarantees > https://golang.org/ref/spec#Size_and_alignment_guarantees > > A struct or array type has size zero if it contains no fields (or > elements, respectively) that have a size

[go-nuts] Re: os.Getwd() on windows changes drive letter casing

2017-04-18 Thread peterGo
Andreas, To fix the easyjson library, please provide a simple recipe for reproducing the error. A complete runnable program is good. A link on play.golang.org is best. What did you expect to see? What did you see instead? Peter On Tuesday, April 18, 2017 at 3:14:47 AM UTC-4, Andreas

[go-nuts] Re: os.Getwd() on windows changes drive letter casing

2017-04-18 Thread peterGo
Guy, It's easy to get any result you want: same case, different case. It's an easyjson problem. Peter On Tuesday, April 18, 2017 at 8:55:03 AM UTC-4, Guy Allard wrote: > > I do net see that here. C: is uppercase in both cases. > > go 1.8 > Win 7 > > On Monday, April 17, 2017 at 11:06:50 AM

[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

[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:

[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: Trying to understand Go benchmarking

2017-08-10 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: A small question on os.FileInfo

2017-08-13 Thread peterGo
y, 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. >> >> File o

[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

[go-nuts] Re: API patterns for a function with a single argument that is rarely needed

2017-07-07 Thread peterGo
Sam, Good naming is such a key part of a good API that the use of sterile names like Foo and Bar during design is doomed to failure. Perhaps it's like packages fmt and log: a default output and a user defined output. For example fmt.Print, fmt.Fprint. You have two functions. Peter On

[go-nuts] Re: Can't explain Golang benchmarks

2017-07-16 Thread peterGo
When you have data races the results are undefined. $ go version go version devel +dd81c37 Sat Jul 15 05:43:45 2017 + linux/amd64 $ go test -race -run=! -bench=. -benchmem -cpu=1,2,4,8 pubsub_test.go == WARNING: DATA RACE Read at 0x00c4200140c0 by goroutine 18:

[go-nuts] Re: Random Number Generation in a given range

2017-07-09 Thread peterGo
Alok, Your import path "github.com/alok87/goutils/random" is not valid for "go get". The source is at "github.com/alok87/goutils/pkg/random". You write "for { rand.Seed(); rand.Intn(); }". Therefore, the range of values is not random. You write "arr[r] = rand.Intn(max) + min" which is

Re: [go-nuts] does Go memory model guarantee this program always prints 1?

2017-07-07 Thread peterGo
T L, No: https://github.com/golang/go/issues/19182 Peter On Friday, July 7, 2017 at 5:31:33 AM UTC, T L wrote: > > > > On Friday, July 7, 2017 at 3:26:24 AM UTC+8, Lars Seipel wrote: >> >> On Thu, Jul 06, 2017 at 12:19:05PM -0700, T L wrote: >> > >> > package main >> > >> > import "fmt" >>

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread peterGo
T L, Why didn't you show us the output from $ go tool compile -m -m clone_test.go ? Peter On Tuesday, June 27, 2017 at 11:33:30 AM UTC-4, T L wrote: > > Ok, I think there are two reasons why the copy version is slower: > 1. the copy version initializes each element twice actutally. > 2.

[go-nuts] Re: Why copy is much slower than append when clone a slice?

2017-06-27 Thread peterGo
= make([]Element, N) copy(y, x) } } ? Peter On Tuesday, June 27, 2017 at 5:59:25 PM UTC-4, peterGo wrote: > > T L, > > Why didn't you show us the output from > > $ go tool compile -m -m clone_test.go > > ? > > Peter > > On Tuesday, June 27, 2017 at

[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 > > >

[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: 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:

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

2017-08-22 Thread peterGo
y-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 wrote: >

Re: [go-nuts] GC problem

2017-05-03 Thread peterGo
es will be used by default for non-lvm based installations." Peter On Wednesday, May 3, 2017 at 2:19:25 PM UTC-4, peterGo wrote: > > Serhat Şevki Dinçer, > > "why cant peterGo reproduce the crash?" > > Because I have swap space. > > $ go build ssd.go > $ ca

Re: [go-nuts] GC problem

2017-05-03 Thread peterGo
Serhat Şevki Dinçer, "why cant peterGo reproduce the crash?" Because I have swap space. $ go build ssd.go $ cat /proc/swaps FilenameType SizeUsedPriority /dev/sda5 partition79994840 -1 $ ./ssd 8 9 $ cat /proc/swap

[go-nuts] Re: Problems refactoring call to Open()

2017-06-21 Thread peterGo
Michael, func openFile(s string, file *os.File) { file, err := os.Open(s) if err != nil { log.Fatal(err) } defer file.Close() } You open the file and when the function exits, close the file. Peter On Wednesday, June 21, 2017 at 12:44:36 PM UTC, Michael Dwyer wrote: > > Hello to all, > > My

[go-nuts] Re: Problems refactoring call to Open()

2017-06-21 Thread peterGo
Michael, In Go, all arguments are passed by value. Therefore the value of file is discarded at the end of openfile. In main, f remains nil. Peter On Wednesday, June 21, 2017 at 4:58:58 PM UTC, Michael Dwyer wrote: > > Peter, > > Thank you for your input regarding my question. > > In an effort

[go-nuts] Re: Problems refactoring call to Open()

2017-06-21 Thread peterGo
Michael, func openFile(s string, file *os.File) { file, err := os.Open(s) if err != nil { log.Fatal(err) } defer file.Close() } There are two errors. When openfile returns file is closed and it is no longer valid. In Go, all arguments are passed by value, When openFile

[go-nuts] Re: Problems refactoring call to Open()

2017-06-21 Thread peterGo
Michael, Your first post was clear. Therefore the error remains. When you close the file you lose the fd. f is nil. For example, package main import ( "bufio" "flag" "fmt" "log" "os" ) func cli() string { flag.Parse() return flag.Arg(0) } func openFile(s string,

[go-nuts] Re: what can I do with this 'workspace' Google have given me?

2017-05-18 Thread peterGo
Sam, Your problems stem from this change: Go 1.8 Release Notes Default GOPATH https://golang.org/doc/go1.8#gopath The GOPATH environment variable (https://golang.org/cmd/go/#hdr-GOPATH_environment_variable) now has a default value if it is unset. It defaults to $HOME/go on Unix and

[go-nuts] Re: Go 1.8.3 is released

2017-05-25 Thread peterGo
Chris, When updating Go source to go1.8.3, I encountered this error: ~ $ cd go/src ~/go/src $ git pull remote: Counting objects: 11146, done remote: Finding sources: 100% (528/528) remote: Total 528 (delta 232), reused 503 (delta 232) Receiving objects: 100% (528/528), 682.08 KiB | 505.00 KiB/s,

[go-nuts] Re: Go 1.8.3 is released

2017-05-25 Thread peterGo
Chris, VERSION: <<<<<<< HEAD go1.8.1 === go1.8.3 >>>>>>> 352996a381701cfa0c16e8de29cbde8f3922182f Peter On Thursday, May 25, 2017 at 9:16:39 AM UTC-4, peterGo wrote: > > Chris, > > When updating Go source to go1.8.3, I encounter

[go-nuts] Re: Guidance on exposing functionality

2017-06-06 Thread peterGo
M2, The Go strconv package (https://golang.org/pkg/strconv/) contains the simple forms Atoi and Itoa and the complex forms ParseInt and FormatInt. In the documentation for each function refer to the alternate form. Peter On Tuesday, June 6, 2017 at 3:56:43 PM UTC-4, M2 wrote: > > I need to

Re: [go-nuts] understanding utf-8 for a newbie

2017-05-07 Thread peterGo
Sam, "I'd be suprised if Windows didn't understand UTF-8 these days," Be surprised! For Unicode, Microsoft Windows uses UTF-16. Peter On Sunday, May 7, 2017 at 11:29:53 AM UTC-4, Sam Whited wrote: > > On Sun, May 7, 2017 at 9:44 AM, rob solomon > wrote: > > I now

Re: [go-nuts] understanding utf-8 for a newbie

2017-05-07 Thread peterGo
Sam, "[Rob Pike and Ken Thompson] they made sure it was backwards compatible with ASCII." ASCII is 7-bits. Peter On Sunday, May 7, 2017 at 11:29:53 AM UTC-4, Sam Whited wrote: > > On Sun, May 7, 2017 at 9:44 AM, rob solomon > wrote: > > I now understand that the bytes

Re: [go-nuts] GC problem

2017-05-01 Thread peterGo
I am unable to reproduce your issue. $ cat /proc/meminfo | grep 'MemTotal' MemTotal:3946772 kB $ uname -v -p -r -s Linux 4.4.0-75-generic #96-Ubuntu SMP Thu Apr 20 09:56:33 UTC 2017 x86_64 $ go version go version go1.8.1 linux/amd64 $ cat ssd.go package main import ( "fmt"

Re: [go-nuts] strange benchmark result: inline is slower than function calls

2017-05-01 Thread peterGo
T L, First, keep things simple. Delete the main function; it's an irrelevant complication. Use shorter function names. Start simply and build one feature at a time. Function is exactly like except that variables are substituted for the function parameter. Function is exactly

Re: [go-nuts] strange benchmark result: inline is slower than function calls

2017-05-01 Thread peterGo
T L, .go : https://play.golang.org/p/GPGO7YnLxh Peter On Monday, May 1, 2017 at 1:15:38 PM UTC-4, peterGo wrote: > > T L, > > First, keep things simple. Delete the main function; it's an irrelevant > complication. Use shorter function names. Start simply and build one >

[go-nuts] Re: download link - 400 error code

2017-05-05 Thread peterGo
Please provide detailed instructions for reproducing your error. Are you usin an Iranian IP address? Peter On Friday, May 5, 2017 at 7:51:43 AM UTC-4, Abbas Naghdi wrote: > > I have a golang 1.8.1 . > but i can't download it . > > please fix error code 400 and 403 thanks . > > -- You received

Re: [go-nuts] Possible optimization bug in go1.8?

2017-05-08 Thread peterGo
Ryan, It's not weird. https://play.golang.org -> About In the playground the time begins at 2009-11-10 23:00:00 UTC (determining the significance of this date is an exercise for the reader). This makes it easier to cache programs by giving them deterministic output. Peter On Monday, May 8,

[go-nuts] Re: understanding utf-8 for a newbie

2017-05-06 Thread peterGo
rob, Why are you converting UTF-8 to ASCII for Windows 10? Convert UTF-8 to CP1252 (Windows-1252) or UTF16. For UTF-8 to CP1252: https://play.golang.org/p/BBiN2ihc02 Peter On Friday, May 5, 2017 at 9:11:16 PM UTC-4, rob solomon wrote: > > Hi. I decided to write a small program in Go to

[go-nuts] Re: understanding utf-8 for a newbie

2017-05-06 Thread peterGo
rob, Why are you converting UTF-8 to ASCII for Windows 10? Convert UTF-8 to CP1252 (Windows-1252) or UTF16. Corrected link. For UTF-8 to CP1252: https://play.golang.org/p/vzupJY78XB Peter On Friday, May 5, 2017 at 9:11:16 PM UTC-4, rob solomon wrote: >

[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 :

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]

[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() {

[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: 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: 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

[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: 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

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

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

2017-08-31 Thread peterGo
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: > > Michael, &g

[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"

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

2017-11-13 Thread peterGo
/play.golang.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: 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

[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: 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

[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: 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

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

[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=rep1=pdf For example, $ go version go version

[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

[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

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 >

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

[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

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: >

[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

  1   2   3   >