Re: [go-nuts] How to properly get basename under DOS?

2016-06-14 Thread Jan Mercl
Package path is for *nix paths only. import "path/filepath" instead. On Tue, Jun 14, 2016, 18:55 Tong Sun wrote: > I thought to get basename, we should use the official *path.Base* -- > https://golang.org/pkg/path/#Base > > However, I just found out that it is *not working

Re: [go-nuts] Send us your gophers!

2016-06-21 Thread Jan Mercl
On Sat, May 21, 2016 at 8:28 AM 'Andrew Gerrand' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Renee French and I are doing a little secret project and would love it if you would draw a gopher and sent it to us. Hi Andrew, is / will be there be some public output of your little

Re: [go-nuts] feature request: allow literal digit underscore grouping

2016-06-22 Thread Jan Mercl
On Wed, Jun 22, 2016 at 5:54 PM Bakul Shah wrote: That can be dealt with an output format. Just as the hex or octal or the "e" input format is lost. > ... in Go there is a slight inconsistency: 1e6 is an int but 1e-6 is a float. The literals 1e6 and 1e-6 are both untyped

Re: [go-nuts] feature request: allow literal digit underscore grouping

2016-06-22 Thread Jan Mercl
On Wed, Jun 22, 2016 at 5:56 PM Andy Balholm wrote: > The same is true of brace styles :-P. Brace style is a matter of preference. Wrong digit grouping in a given place on Earth is wrong, not less preferred. -- -j -- You received this message because you are

Re: [go-nuts] Result is sometimes different despite using same value when encode by encoding/gob

2016-06-21 Thread Jan Mercl
On Tue, Jun 21, 2016 at 7:44 AM Harry wrote: > Why serialized value is not invaliable when using map value. Map keys are comparable but they are not required to be ordered , ie. sorting them before serializing is not only

Re: [go-nuts] Trying to dynamically find interfaces

2016-06-27 Thread Jan Mercl
On Mon, Jun 27, 2016 at 4:16 PM David Koblas wrote: type BaseAppController struct { *Application IGet IList } The above means that every instance of BaseAppController satisfies both the IGet and IList interfaces

Re: [go-nuts] small defect in os.exec.LookPath

2016-06-25 Thread Jan Mercl
On Sat, Jun 25, 2016 at 11:19 PM mhhcbon wrote: > bin, err := exec.LookPath(os.Args[0]) Note that this err variable is shadowing the one declared previously. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] Question - type assertion x.(*T)

2016-06-28 Thread Jan Mercl
On Tue, Jun 28, 2016 at 11:13 AM Michael Wain wrote: > Why would I use *T over just T ? Consider this program package main import ( "fmt" ) type T int func main() { var a, b T = 42, 314

Re: [go-nuts] Append to slice... what happens?

2016-06-26 Thread Jan Mercl
On Mon, Jun 27, 2016 at 12:26 AM Peter Kleiweg wrote: > I don't know what I expected, but it's weird. Don't mess with slices. Well, working as expected, considering slice backing array is possibly shared wrt the result of append. (Or other slice op, b/c slices _are_ values.)

[go-nuts] [ANN] bench

2016-07-22 Thread Jan Mercl
>From the today-I-needed department: Bench[0] is a tool for running package benchmarks in isolation, one by one. [0]: https://godoc.org/github.com/cznic/bench -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this

Re: [go-nuts] ioutil.WriteFile and Sync

2016-07-21 Thread Jan Mercl
On Thu, Jul 21, 2016 at 8:17 PM Manlio Perillo wrote: > What is the reason why ioutil.WriteFile does not call File.Sync? That would be harmful. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

Re: [go-nuts] Is it weird?

2016-07-25 Thread Jan Mercl
On Mon, Jul 25, 2016 at 5:34 PM T L wrote: I cannot see a problem. > ().f() // ok is a pointer, no problem here. > t.f() // ok t is adressable, again, no problem. > ({}).f() // ok {} is already a pointer, no surprise it's ok as a receiver of a pointer method. >

Re: [go-nuts] mysql driver ?

2016-08-02 Thread Jan Mercl
On Tue, Aug 2, 2016 at 4:21 PM Victor L wrote: > I have to query mysql database in my code...Do i need to add github mackage for mysql driver? import ( _ "github.com/go-sql-driver/mysql" ) yes -- -j -- You received this message because you are subscribed to the Google

Re: [go-nuts] why the method set of *T is the superset of the method of T even if values of both *T and T can call both methods of *T and T?

2016-07-16 Thread Jan Mercl
On Sat, Jul 16, 2016 at 9:42 AM T L wrote: > is there any logic here? Or just a hard rule? https://play.golang.org/p/4YVDq2XLln -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] How can I get running func name?

2016-07-13 Thread Jan Mercl
On Wed, Jul 13, 2016 at 1:48 PM Harry wrote: > If I could get func name automatically, same code can be used. https://play.golang.org/p/XjDcnK78xY -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

Re: [go-nuts] How can I get running func name?

2016-07-13 Thread Jan Mercl
On Wed, Jul 13, 2016 at 3:56 PM Harry wrote: > I want to keep something records as log and where it is to specify. Many loggers are able to include the file_name:line_number info, which is cheaper to obtain at runtime. -- -j -- You received this message because you are

Re: [go-nuts] Re: why the method set of *T is the superset of the method of T even if values of both *T and T can call both methods of *T and T?

2016-07-16 Thread Jan Mercl
On Sat, Jul 16, 2016 at 1:51 PM Torsten Bronger < bron...@physik.rwth-aachen.de> wrote: > There still is a subtle asymmetry: a.b() is implicitly converted to ().b() if necessary. Why isn't f(v) implicitly converted to f() if necessary? Go does not do implicit conversions of types of run time

Re: [go-nuts] Using "map index expressions" as the value for a range loop

2016-07-07 Thread Jan Mercl
On Thu, Jul 7, 2016 at 4:06 PM Kyle Stanly wrote: > for k, m[k] := range m {...} > > Apparently is valid Go syntax, however what are the semantics behind this? It is not a valid Go syntax. The short variable declaration syntax requires variable names on its left side. You

Re: [go-nuts] How to allocate memory from OS in compatible way.

2016-07-11 Thread Jan Mercl
On Mon, Jul 11, 2016 at 4:37 PM wrote: > I unable to find standard mmap for windows in Go library, that was originial question. Use case is processing of large (several millions of nodes) trees. I have not used it yet: https://github.com/edsrzf/mmap-go -- -j -- You

Re: [go-nuts] function with goroutine returned will kill its goroutine?

2016-07-04 Thread Jan Mercl
On Mon, Jul 4, 2016 at 5:08 PM Kenshin Wang wrote: go func(i int) { for { next <- i i++ } }(start) > could anyone can explain why the output is this? A goroutine dies when it

Re: [go-nuts] ioutil.WriteFile and Sync

2016-07-22 Thread Jan Mercl
On Fri, Jul 22, 2016 at 12:40 PM Manlio Perillo wrote: > I really don't see valid reasons to not call Sync. There are valid use cases where WriteFile produces a transitive file with no requirements whatsoever to reach any storage above the kernel caches. Performance in

Re: [go-nuts] Will go compiler do optimization here if "bytes" is a global variable?

2016-07-23 Thread Jan Mercl
On Sat, Jul 23, 2016 at 9:03 PM T L wrote: > If "bytes" is a local variable, it is reasonable the compiler will do the optimization. > But how about if "bytes" is a global variable? Not sure what a global variable is. Go has universe scope, but user code cannot declare

Re: [go-nuts] map values visibility when the map is populated in a goroutine yet used in another ?

2016-08-15 Thread Jan Mercl
On Mon, Aug 15, 2016 at 5:28 PM atd...@gmail.com wrote: > Is there an happen/before edge between spawning a goroutine and the map operations ? Yes: https://golang.org/ref/mem#tmp_5 -- -j -- You received this message because you are subscribed to the Google Groups

[go-nuts] Regexp question

2016-08-16 Thread Jan Mercl
This code (A) package main import ( "fmt" "regexp" ) func main() { fmt.Printf("%v", regexp.MustCompile(`a*`).FindAllStringIndex(`baaab`, -1)) } (https://play.golang.org/p/WeyStT0Gbn) Produces [[0

Re: [go-nuts] Is there a "strings.Clone(string) string" alike function?

2017-02-01 Thread Jan Mercl
On Wed, Feb 1, 2017 at 10:19 AM T L wrote: > newStr := string([]byte(oldStr)) is simple but will make two memory allocations, and one of them is a waste. Is the above an assumption or have you verified that? It would not surprise me that nowadays the compiler can infer the

Re: [go-nuts] Is there a "strings.Clone(string) string" alike function?

2017-02-01 Thread Jan Mercl
On Wed, Feb 1, 2017 at 10:59 AM T L wrote: > It is obviously that both strings.Repeat and string([]byte(s)) make two 1M memory allocations. The observation is correct. However, stack allocating of non-leaking items is capped in size and I guess 1M is out of limits. The

Re: [go-nuts] About 64bits alignment

2017-02-01 Thread Jan Mercl
On Wed, Feb 1, 2017 at 5:04 PM T L wrote: > But what does an allocated struct or slice means? A struct or slice allocated on heap, not stack? There's no heap nor stack from the POV of the language spec. Allocated means appropriate amount of storage is now used by the

Re: [go-nuts] Cross Compiling and Go Native and "What is a C library"

2017-01-26 Thread Jan Mercl
On Thu, Jan 26, 2017 at 6:46 PM wrote: > "If you want to use any C libraries" Don't all programs use C libraries... When I use sysinternals procmon a windows Go exe uses tens (almost hundreds) of OS c libraries. On linux/bsd I have not checked, but you cannot possibly get

Re: [go-nuts] Cross compile GOOS

2017-01-26 Thread Jan Mercl
On Thu, Jan 26, 2017 at 7:10 PM wrote: > go build os=bsd prog > Or is it by design that you cannot just compile using a compiler switch, you must set GOOS environment variable? $ GOOS=bsd go build prog $ go build -os bsd prog The difference in length is only one letter anyway

Re: [go-nuts] What is use for [:] of a slice?

2017-01-30 Thread Jan Mercl
On Mon, Jan 30, 2017 at 7:44 PM Andy Balholm wrote: > Anyway, I can’t think of any reason to use [:] on a slice either. reasons[:]: https://play.golang.org/p/PN9qBf13Th ;-) -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Priority cases in select?

2017-01-25 Thread Jan Mercl
On Wed, Jan 25, 2017 at 2:14 PM T L wrote: > sometimes, I do want one case on a select block get selected even if there are multiple unblocked cases. > For example, I don't want the dataCh case is selected if the stopCh and the timer channel are unblocked: select {

Re: [go-nuts] Re: Priority cases in select?

2017-01-25 Thread Jan Mercl
On Wed, Jan 25, 2017 at 5:00 PM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > I don't believe the actual use case described can be mapped. From what I understand, the intended behavior was > a) put the goroutine to sleep until some communication can proceed > b) if

Re: [go-nuts] Re: invitation to gophers.slack.com

2017-01-20 Thread Jan Mercl
On Tue, Dec 13, 2016 at 12:10 PM Damian Gryski wrote: > You must be a member of the Gophers Slack to see the message achive. This reminds me... In a long-ish time span, I more than once tried applying for membership using the link provided by Dave in this thread. Never got

Re: [go-nuts] Cross Compiling and Go Native and "What is a C library"

2017-01-26 Thread Jan Mercl
On Fri, Jan 27, 2017 at 6:25 AM Aram Hăvărneanu wrote: > On Solaris the syscall interface is a private, unstable interface (just like on Windows), and the only supported way to interact with the system is through the vendor-supplied libc. Go on Solaris always uses libc, it doesn't

Re: [go-nuts] will GC close unused connection ?

2017-02-15 Thread Jan Mercl
On Thu, Feb 16, 2017 at 8:20 AM wrote: > Will GC close unused connection ? No. At least not directly. A finalizer can possibly do that and finalizers are possibly invoked by the GC. -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Goroutine in a for loop: Closure versus direct

2017-02-25 Thread Jan Mercl
> I think both these approaches are fine, but just wanted to check. They're not, #2 has a data race. -- -j -- 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

Re: [go-nuts] Unexpected Behaviour of goroutine

2017-02-12 Thread Jan Mercl
On Sun, Feb 12, 2017 at 11:51 AM Srivathsan Madhavan wrote: A race detector should complain about write to i here for i := 0; i < 5; i++ { concurrently with reading i here log.Println("i=", i) Passing i to the goroutine, instead of sharing it should

Re: [go-nuts] Go Optimizations for IO Intensive programs

2017-02-12 Thread Jan Mercl
On Sat, Feb 11, 2017 at 1:58 AM wrote: > Are there any other methodologies where I can optimize compresssion part and upload part Many ISPs have upload speed several times slower than download. The symptoms you described would be consistent with that. But maybe you

Re: [go-nuts] CodeReviewComments: Recommendation of gofmt

2017-02-11 Thread Jan Mercl
On Sat, Feb 11, 2017 at 5:07 PM Axel Wagner wrote: > What about a) vs. c)? c) is fine, but as it's a matter of personal taste, ie. it's IMO more or less bike shedding. IOW, whatever choice as long as it's a single one. Actually, the split goimports bring to the

Re: [go-nuts] Why get an element from []interface{} `arr[0] == nil` is not true?

2017-02-15 Thread Jan Mercl
On Wed, Feb 15, 2017 at 9:40 AM Felix Sun wrote: Why `arr[0] == nil` is not true? Because it's not a nil interface{}: https://play.golang.org/p/w-od_KHWlc See also https://golang.org/doc/faq#nil_error -- -j -- You received this message because you are subscribed to the

Re: [go-nuts] [Proposal] Std Lib Logging Abstraction

2017-02-12 Thread Jan Mercl
On Mon, Feb 13, 2017 at 8:44 AM Sotirios Mantziaris wrote: > ... which prohibit me of using anything else if i want to have a consistent logging experience. What does "consistent logging experience" mean? -- -j -- You received this message because you are subscribed

Re: [go-nuts] Why get an element from []interface{} `arr[0] == nil` is not true?

2017-02-16 Thread Jan Mercl
On Thu, Feb 16, 2017 at 8:20 PM Dragos Harabor wrote: > Is there any way to check whether the value stored in a non-nil interface is nil when you don't know the type, short of using reflect.Value.IsNil()? For example: https://play.golang.org/p/Sdqx7Frjxj -- -j -- You

Re: [go-nuts] CodeReviewComments: Recommendation of gofmt

2017-02-11 Thread Jan Mercl
On Sat, Feb 11, 2017 at 4:30 PM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Am I alone in being bothered by this? ^^ My personal opinion is that a tool that can, even potentially, turn a valid program into an invalid one, or worse, silently into another valid program

Re: [go-nuts] Are receivers from a channel fifo?

2016-08-21 Thread Jan Mercl
On Sun, Aug 21, 2016, 22:43 Steven Hartland wrote: > If I have multiple goroutines reading from a channel are they guaranteed > to be FIFO i.e. is the handler that requested the read first guaranteed to > get the first value, second to get the second and so on? > > Values

Re: [go-nuts] Understanding go routine heap

2016-08-20 Thread Jan Mercl
On Sat, Aug 20, 2016 at 8:29 AM Yulrizka wrote: > He argues that this is heap race condition. I don't know what is a heap race condition but the code is race free. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group.

Re: [go-nuts] Slice from interface doesn't work as expected

2017-03-02 Thread Jan Mercl
On Thu, Mar 2, 2017 at 2:46 PM wrote: > Can somebody explain me why? Did you mean https://play.golang.org/p/GUVZBUQlEj ? -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] Named embedded structs?

2016-08-24 Thread Jan Mercl
On Thu, Aug 25, 2016, 00:08 Sam Salisbury wrote: > Would it be nice or nasty for this to work? > https://play.golang.org/p/iCTKx3gF_2 > > Copy-pasted: > > type Thing struct { > Embedded struct { > Name string > } > } > > func main() { > x := Thing.Embedded{Name: "Barry"}

Re: [go-nuts] interactive debugger for go ??

2016-09-08 Thread Jan Mercl
On Thu, Sep 8, 2016 at 10:37 AM Florin Pățan wrote: > Delve is the Go debugger. fmt.Printf is the Go debugger. /ducks -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] I want to deep copy a map, how to get an enough initial size for the second parameter of make function?

2016-09-08 Thread Jan Mercl
On Thu, Sep 8, 2016 at 3:32 PM T L wrote: > With the enough initial size, the underlying hashtable of the new map will never need to be realloced in the whole copy process. For example dst := make(map[T]U, len(src)) See also

Re: [go-nuts] Is there the incompatibility risk when using the XxxxPointer functions in sync/atomic package in later go versions?

2016-09-08 Thread Jan Mercl
On Thu, Sep 8, 2016 at 2:51 PM T L wrote: > Aren't the parameters of atomic.Load/Store/SwapPointer functions (*)unsafe.Pointer? Yes, they are. Using any package API that involves unsafe.Pointer implies your program must "import unsafe" to use it. And that means your program

Re: [go-nuts] reasonable or not?

2016-09-07 Thread Jan Mercl
On Wed, Sep 7, 2016 at 4:56 PM T L wrote: Reasonable. -- -j -- 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

Re: [go-nuts] Is there the incompatibility risk when using the XxxxPointer functions in sync/atomic package in later go versions?

2016-09-07 Thread Jan Mercl
On Wed, Sep 7, 2016 at 4:54 PM T L wrote: https://golang.org/doc/go1compat -- -j -- 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

Re: [go-nuts] Nil interface/pointer

2016-09-10 Thread Jan Mercl
On Sat, Sep 10, 2016 at 5:52 PM Kiki Sugiaman wrote: Question: can I determine whether f1 is nil given only f2 to check? f2 is not (the untyped) nil. The thing inside f2 is possibly (a typed) nil. For example: https://play.golang.org/p/E-It6kkgSw -- -j -- You received

Re: [go-nuts] Defective information output??? (To Developers)

2016-09-13 Thread Jan Mercl
On Tue, Sep 13, 2016 at 2:19 PM Александр Петров wrote: > Consult me. I believe that the displayed information is incorrect and should be changed in future versions of the language. > What I see, it is of little help in debugging. https://play.golang.org/p/jQJJoknb3v

Re: [go-nuts] Static race detector?

2016-09-13 Thread Jan Mercl
On Tue, Sep 13, 2016 at 7:53 AM josvazg wrote: > Why does Go does not have a static race detector? What are the difficulties? For example, the halting problem. Ok, now seriously. > If Rust can do it, using its ownership model, Go could have a tool checking the AST that

[go-nuts] Parsing ambiguity?

2016-09-16 Thread Jan Mercl
Consider this program (https://play.golang.org/p/V0fu9rD8_D) package main import ( "fmt" ) func main() { c := make(chan int, 1) c <- 1 d := <-chan int(c) fmt.Printf("%T\n", d)

Re: [go-nuts] what's the difference between Golang and Java about interface?

2016-10-08 Thread Jan Mercl
On Sat, Oct 8, 2016, 16:39 Pietro Gagliardi wrote: > > > Go does not have functional interfaces or interface literals. > I don't know what is meant by 'functional interfaces' but Go definitely supports interface literals. -- -j -- You received this message because you

Re: [go-nuts] Re: .net core vs go

2016-10-09 Thread Jan Mercl
On Sun, Oct 9, 2016 at 10:37 AM Sotirios Mantziaris wrote: > Still much faster than go! That basically compares the cost of creating like 4 threads to creating 100k goroutines. -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] incomplete stack trace

2016-10-07 Thread Jan Mercl
On Fri, Oct 7, 2016 at 7:39 AM Dan Kortschak wrote: > I have just been given the following stack trace for a program I working on. The trace terminates before it gets into my program, making it's utility close to zero. Does anyone have any idea why it is not

Re: [go-nuts] Re: .net core vs go

2016-10-08 Thread Jan Mercl
On Wed, May 18, 2016 at 4:06 PM Sotirios Mantziaris wrote: > The claim that .Net is not heavily concurrent is not true either. A Go program executing 100k goroutines needs 200MB or 400MB RAM for stack, depending on version, so it can run just fine. A .net program trying

Re: [go-nuts] Install vim-go as a pacakge in vim 8

2016-09-19 Thread Jan Mercl
On Sun, Sep 18, 2016 at 10:46 AM Johann Höchtl wrote: > I thought Vim 8 packages are all automatic. vim-go commands like :help vim-go or :GoUpdateBinaries do not work. Are you using the vim-8.0 branch? ( https://github.com/fatih/vim-go/tree/vim-8.0) -- -j -- You

Re: [go-nuts] Ivy crashes on iOS 10

2016-09-19 Thread Jan Mercl
On Mon, Sep 19, 2016 at 3:58 PM wrote: > Anybody with same experiences? https://github.com/robpike/ivy/issues/29 -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] idea behind error interface and github.com/pkg/errors

2016-09-23 Thread Jan Mercl
Nothing prevents you from including the call stack in the error message. Especially if you prefer the way how Java error messages look. I don't. On Fri, Sep 23, 2016, 08:24 Yulrizka wrote: > Hello > > I was watching Dave Cheney's presentation in gopher conf and was >

Re: [go-nuts] Sorting slice of structs

2016-09-20 Thread Jan Mercl
Types []Course and Courses are distinct types. courses have type []Courses because that's what the parameter to make is. Change it to Courses, ie. courses := make(Courses, maxrow) On Tue, Sep 20, 2016, 19:44 Arie van Wingerden wrote: > Hi, > > Still a beginner ... first take

Re: [go-nuts] Parsing ambiguity?

2016-09-16 Thread Jan Mercl
On Fri, Sep 16, 2016 at 4:02 PM Ian Lance Taylor wrote: > The rule you are looking for is at https://golang.org/ref/spec#Conversions : "If the type starts with the operator * or <-, or if the type starts with the keyword func and has no result list, it must be parenthesized when

Re: [go-nuts] Re: Parsing ambiguity?

2016-09-16 Thread Jan Mercl
On Fri, Sep 16, 2016 at 4:13 PM adonovan via golang-nuts < golang-nuts@googlegroups.com> wrote: > The grammar is indeed ambiguous, but the ambiguity is (implicitly) resolved by favoring the leftmost derivation, which is what you get from an LL(k) parser. By the same token (hah!), the grammar

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Jan Mercl
On Fri, Aug 26, 2016, 17:45 T L wrote: > > > package main > > type Age int > > func main() { > var ages = []Age{17, 18, 19} > var ints = ([]int)(ages) // error: cannot convert ages (type []Age) to > type []int > _ = ints > } > Because Go is a type safe language.

Re: [go-nuts] Why can't convert []T to []T2 if T2 is a copy definition of T?

2016-08-26 Thread Jan Mercl
On Fri, Aug 26, 2016, 17:59 T L wrote: > > >> -- >> > > why the underlying types of []Age and []int are not the same. > The underlying type of an anonymous type []T is []T. -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Length of Channel Using len Function

2016-08-28 Thread Jan Mercl
Using len(ch) like this in a concurrency scenario is a big no because then the value you get carries 0 bits of useful information. It's not a data race, it's worse, the race is semantic and not fixable without removing the use of len(ch). On Sun, Aug 28, 2016, 17:26 dc0d

Re: [go-nuts] Why can't you take the address of a function's return value?

2016-08-22 Thread Jan Mercl
On Mon, Aug 22, 2016, 19:24 wrote: > Hey All, > > I've been using a typedef of > > type MaybeTimestamp *int64 > > so we can JSON encode timestamps correctly, see > https://medium.com/coding-and-deploying-in-the-cloud/time-stamps-in-golang-abcaf581b72f > for inspriation

Re: [go-nuts] type-embeded consts and variables request

2016-09-25 Thread Jan Mercl
On Sun, Sep 25, 2016 at 6:07 PM Ally Dale wrote: > Exactly, I desired my extension code can be like this: type Duration time.Duration const Duration.Day = Duration(time.Duration.Hour*24) const Duration.Week = Duration(Duration.Day*7) I'm perhaps missing something, but you can

Re: [go-nuts] How to define two identical named types?

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016, 10:54 T L wrote: > > > Then how are they defined? > Discussed earlier in this thread: they are predeclared. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] How to define two identical named types?

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016 at 9:48 AM T L wrote: > If no two custom named types are identical, why spec says that? Because identical named types do exists. You have already listed them. -- -j -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] How to define two identical named types?

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016 at 11:27 AM T L wrote: > If they are predeclared, then is it meaningless to say their type names originate in the same TypeSpec? I don't know why do you think it's meaningless. byte and uint8 share the same

Re: [go-nuts] How to define two identical named types?

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016, 10:25 T L <tapir@gmail.com> wrote: > > > On Saturday, October 1, 2016 at 4:02:14 PM UTC+8, Jan Mercl wrote: > > On Sat, Oct 1, 2016 at 9:48 AM T L <tapi...@gmail.com> wrote: > > > If no two custom named types are identical, why spec sa

Re: [go-nuts] How to define two identical named types?

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016, 09:13 T L wrote: > In Go spec, https://golang.org/ref/spec#Type_identity, it says: > > Two named types are identical if > their type names originate in the same TypeSpec >

Re: [go-nuts] How to define two identical named types?

2016-10-01 Thread Jan Mercl
> but we even don't know how the builtin byte and uint8 are defined? Yes we know, see: https://golang.org/ref/spec#Numeric_types > How do you know their type names originate in the same TypeSpec? Because that's how the semantics of predeclared

Re: [go-nuts] How to define two identical named types?

2016-10-01 Thread Jan Mercl
On Sat, Oct 1, 2016 at 4:28 PM T L wrote: > I know this byte and uint8 are identical in syntax. They are identical semantically. > But they are not defined with TypeSpec style described in the go spec. It's not possible to

Re: [go-nuts] spec:

2016-10-10 Thread Jan Mercl
On Mon, Oct 10, 2016 at 6:29 PM T L wrote: > So, two non-exported identifiers spelled same but in different packages are the same identifiers? See Ian's answer. Note also the specs's preceding sentence: "Given a set of identifiers." -- -j -- You received this message

Re: [go-nuts] Are short variable declarations necessary?

2016-11-09 Thread Jan Mercl
On Wed, Nov 9, 2016 at 1:00 PM T L wrote: > many? I see only two ones. v := expr var v = expr var v T var v T = expr -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] premature defer in method when using cgo

2016-11-10 Thread Jan Mercl
On Thu, Nov 10, 2016 at 3:31 PM wrote: > So defer is executed before the method exits. Does log.Debug flush its output before returning? -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] godoc: display a full file example

2016-11-07 Thread Jan Mercl
On Mon, Nov 7, 2016 at 9:08 PM wrote: > Can someone highlight my mistake ? "The entire test file is presented as the example when it contains a single example function, at least one other function, type, variable, or constant declaration, and no test or benchmark functions.

Re: [go-nuts] interface as valid method receivers ?

2016-10-19 Thread Jan Mercl
On Wed, Oct 19, 2016 at 8:58 PM Viktor Kojouharov wrote: > Not really, as this is all hypothetical, it might be implemented in a way so that any type that wants to satisfy an interface with default methods has to at least implement all non-default ones. That is to say,

Re: [go-nuts] Go 1.7.3 is released

2016-10-19 Thread Jan Mercl
On Wed, Oct 19, 2016 at 9:45 PM Chris Broadfoot wrote: > We have just released Go version 1.7.3, a minor point release. Package time fails test. jnml@4670:~$ cd ~/go/src/ jnml@4670:~/go/src$ go env GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux"

Re: [go-nuts] What is called reference values in Golang?

2016-10-19 Thread Jan Mercl
On Wed, Oct 19, 2016 at 12:27 PM T L wrote: Nothing. The language specification does not mention it. People use that term based on definitions specified for other programming languages, but those are not always equal to each other. -- -j -- You received this message

Re: [go-nuts] Are short variable declarations necessary?

2016-10-19 Thread Jan Mercl
On Wed, Oct 19, 2016 at 12:51 PM T L wrote: > but I don't want to leak i in outer block, and adding a {} pair is overkill. That's an example answering the question in the title of this thread. -- -j -- You received this message because you are subscribed to the Google

Re: [go-nuts] The [low:high] expression for creating slices

2016-10-20 Thread Jan Mercl
On Thu, Oct 20, 2016 at 10:45 AM Nyah Check wrote: > My understanding of the [low:high] expression is Go is creating slices when you're copying data from an already existing slice. Is it possible to use the expression when you're creating a slice without copying data from

Re: [go-nuts] The [low:high] expression for creating slices

2016-10-20 Thread Jan Mercl
On Thu, Oct 20, 2016 at 11:33 AM Nyah Check wrote: > I thought that expression allocates memory corresponding to that region in memory at run time? Or does it just reference only that part of the existing slice. Like it's done with pointers? "If the sliced operand of a

Re: [go-nuts] spec:

2016-10-10 Thread Jan Mercl
On Mon, Oct 10, 2016 at 6:01 PM Paul Borman wrote: > In your representation, P means "identifiers are different", so the resulting false means the identifiers are the same, which is what the OP asked. I put it simple but I still managed to misread my own simple code correctly

Re: [go-nuts] defer with testify/assert

2016-10-14 Thread Jan Mercl
On Fri, Oct 14, 2016 at 4:19 PM Kiki Sugiaman wrote: > Maybe there's something I don't understand about defer. "inside dummyfunc" showing first is correct. The reason is Each time a "defer" statement executes, the function value and parameters to the call are

Re: [go-nuts] Tooling experience feedback

2016-10-18 Thread Jan Mercl
On Tue, Oct 18, 2016 at 8:54 PM 'Jaana Burcu Dogan' via golang-nuts < golang-nuts@googlegroups.com> wrote: The go tool already does a lot of things, perhaps too much of them. The observation that newcomers have trouble to use it to their advantage is both correct and the evidence of its

Re: [go-nuts] allow {3}, {true} etc

2016-10-21 Thread Jan Mercl
On Fri, Oct 21, 2016 at 9:20 PM Nate Finch wrote: > And, I would argue, it actually makes the language slightly more regular, since now {v} works for just about everything (possibly everything?). Taking the address of an addressable thing is the regular proper. Taking

Re: [go-nuts] Loops over sorted array, sort.Sort used as value

2016-10-21 Thread Jan Mercl
sort.Sort has no return value so it cannot be used as an expression, which is what the range clause grammar expects. On Fri, Oct 21, 2016, 20:20 Tong Sun wrote: > Hi, > > How to loop over sorted array? > > I got "sort.Sort used as value" error: >

Re: [go-nuts] There has no Mutex.Trylock() implemention or similar method ?

2016-10-21 Thread Jan Mercl
On Fri, Oct 21, 2016 at 3:05 PM Michael Liu wrote: It's possible to model a lock using a semafor. Semafor can be implemented by a channel. The select statement can be then used for the "tryLock" operation. -- -j -- You received this message because you are subscribed

Re: [go-nuts] Re: Are short variable declarations necessary?

2016-10-21 Thread Jan Mercl
On Fri, Oct 21, 2016 at 4:20 PM Art Mellor < art-googlep...@dontsharemyemail.com> wrote: > x := FooProduce() var x = FooProduce() // Does the same, where applicable. -- -j -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from

Re: [go-nuts] interface as valid method receivers ?

2016-10-19 Thread Jan Mercl
On Wed, Oct 19, 2016 at 5:40 PM Viktor Kojouharov wrote: > That's just a default method implementation. There's nothing inherently confusing about what gets called. If a concrete implementation exists, that gets called, otherwise the default one does. But to assign

Re: [go-nuts] Is it a compiler bug?

2016-11-12 Thread Jan Mercl
On Sat, Nov 12, 2016 at 6:25 PM Michael Jones wrote: >The closest thing to a “super comment” is shown in my edit to your example: https://play.golang.org/p/nkDcMCzhkf > > It is legitimate, but it too has limitations. For me at least, those are rare. Also, prefixing all

Re: [go-nuts] Is it a compiler bug?

2016-11-12 Thread Jan Mercl
On Sat, Nov 12, 2016 at 5:55 PM imd3c wrote: It is not a compiler bug. The /*-style comment ends at the first occurence of */. Content between the /* and the first following */ plays no role. -- -j -- You received this message because you are subscribed to the Google

Re: [go-nuts] Struct field updefined Build Error

2016-11-25 Thread Jan Mercl
On Fri, Nov 25, 2016 at 4:42 PM Chris S wrote: type AggInfoXml struct { Percent IntPercent `xml:"taskprogress,omitempty"` IpAddr []Addr `xml:"host>address,omitempty"` } ... for _, port := range

Re: [go-nuts] Why doens't function type support comparision but channel type does?

2016-11-23 Thread Jan Mercl
On Wed, Nov 23, 2016 at 2:40 PM T L wrote: Functions can be inlined. -- -j -- 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

  1   2   3   4   5   6   7   8   9   10   >