Re: [go-nuts] govulncheck

2024-03-11 Thread Volker Dobler
What exactly beside the information in https://go.dev/blog/govulncheck and especially https://go.dev/doc/tutorial/govulncheck do you want to discuss? V On Monday 11 March 2024 at 00:49:17 UTC+1 Colton Freeman wrote: > Disregard. Figured out the tool (a little better). Would still love to >

[go-nuts] Re: It seems that go 1.22 has optimized the implementation of string to byte slicing and no longer requires memory allocation.

2023-11-27 Thread Volker Dobler
Ah, and one more: On Monday, 27 November 2023 at 13:12:54 UTC+1 fliter wrote: BenchmarkTest1-83572733433.51 ns/op 192 B/op 1 allocs/op BenchmarkTest2-81471724258.157 ns/op 0 B/op 0 allocs/op BenchmarkTest3-8

[go-nuts] Re: It seems that go 1.22 has optimized the implementation of string to byte slicing and no longer requires memory allocation.

2023-11-27 Thread Volker Dobler
On Monday, 27 November 2023 at 13:12:54 UTC+1 fliter wrote: But why not optimize byte slicing to string conversion together? Try to implement that conversion and you'll see. Note that strings are immutable, even if converted from a byte slice (which are by their very nature) mutable. Good luck

Re: [go-nuts] Re: I think in Golang, Array, Slice, and Map , all of them are very difficult to use。

2023-11-09 Thread Volker Dobler
On Thursday, 9 November 2023 at 18:35:38 UTC+1 Viktoriia Kapyrina Yelizarova wrote: ] array_intersect is a common example of automation. It makes no sense to right it again and again as it is common operation which works the same way. Except that almost all implementations of array_intersect

Re: [go-nuts] Re: About allowing conversion from bool to int

2023-10-20 Thread Volker Dobler
; > El vie, 20 oct 2023 a las 14:48, Victor Giordano () > escribió: > >> Volker. I don't know how to reply to what you state. I'm open to listen >> or read any thoughts you have about not using bool to int. >> >> >> El vie, 20 oct 2023 a las 12:20, Volke

[go-nuts] Re: About allowing conversion from bool to int

2023-10-20 Thread Volker Dobler
I use 1 a lot and 4 (or the suggested bool<-->int conv) never. I have no idea what you want to express with 2 and 4 addresses a kind of problem that has no simple solution like a one-line function. V. On Friday, 20 October 2023 at 15:12:06 UTC+2 Victor Giordano wrote: > Hello fellow

[go-nuts] Re: Handling EOF when using json.NewDecoder() from named pipe

2023-10-17 Thread Volker Dobler
have to find some way to read more (???) or reset the Reader and this has nothing to do with _how_ you read from that Reader. V. On Tuesday, October 17, 2023 at 4:37:58 AM UTC-4 Volker Dobler wrote: Why do you use a json.Decoder? It seems as reading everything (io.ReadAll) until EOF

[go-nuts] Re: Handling EOF when using json.NewDecoder() from named pipe

2023-10-17 Thread Volker Dobler
Why do you use a json.Decoder? It seems as reading everything (io.ReadAll) until EOF and json.Unmarshal'ling would be a cleaner/simpler solution? V. On Tuesday, 17 October 2023 at 09:10:09 UTC+2 Christopher C wrote: > Hello all! > I'm trying to read json objects from a named pipe. The pipe

[go-nuts] Re: Best IDE for GO ?

2023-08-21 Thread Volker Dobler
> Best IDE for G[o]? This is hard to answer like most "best" questions. What is the best dish? The best movie. The best vacuum cleaner? But honestly its emacs of course. V On Saturday, 19 August 2023 at 11:27:34 UTC+2 alex-coder wrote: > Hi All ! > Gophers, there is at least 10 years as GO on

[go-nuts] Re: Why not return after calling http.Error()

2023-07-04 Thread Volker Dobler
On Tuesday, 4 July 2023 at 17:39:05 UTC+2 Gurunandan Bhat wrote: Every example of http Handler that I have seen so far looks like this: This is very strange as basically all correct http Handlers I have seen in the last 10 years actually do return after http.Error. If all examples of http

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-13 Thread Volker Dobler
On Monday, 13 March 2023 at 17:41:42 UTC+1 Van Fury wrote: Relating to my previous question, I have been reading but it is still not clear to me what raw binary is, how is it different from text formatted binary (fmt.Sprintf("%b", s1s2Byte))? "text formated binary" takes a stream of bytes and

Re: [go-nuts] How to encode/decode string to binary in golang

2023-03-13 Thread Volker Dobler
On Monday, 13 March 2023 at 12:24:15 UTC+1 Van Fury wrote: Sorry I did not frame my question properly but what I would like to do is to encode concatenated s1 and s2 into raw binary and then decode the raw binary back to s1 and s2. The only problem is knowing where s1 ends / where s2 starts. So

Re: [go-nuts] where is GOROOT set?

2022-12-08 Thread Volker Dobler
You cannot have multiple packages (in your case main and goprorename) in one folder. This has nothing to do with modules. You must but these three files into two different folders based on their package declaration. You might want to work through https://go.dev/doc/code V. -- You received this

Re: [go-nuts] Re: go install of forked repo

2022-12-04 Thread Volker Dobler
On Sunday, 4 December 2022 at 15:13:46 UTC+1 ren...@ix.netcom.com wrote: > Can’t you use a replace directive to use the fork ? > No, not in the general case. V. > > On Dec 4, 2022, at 6:17 AM, Volker Dobler wrote: > > You cannot use a "fork". The Github concept

[go-nuts] Re: go install of forked repo

2022-12-04 Thread Volker Dobler
You cannot use a "fork". The Github concept of a "fork" doesn't work together with the concept of a Go module. You are free to fork a repo and you can modify the source after git cloning your "fork" you even can build the "fork" and go install it's binaries by simply running go install inside of

[go-nuts] Re: Proposal for change type Duration int64

2022-11-22 Thread Volker Dobler
On Tuesday, 22 November 2022 at 11:28:15 UTC+1 nikhil...@gmail.com wrote: > [...] the duration value should never be less than 0 else it will panic > This statement is wrong, a negative time.Duration doesn't panic. (Maybe you are talking about time.Sleep?) Is there any reason for not using uint?

Re: [go-nuts] Error Handling Question

2022-10-23 Thread Volker Dobler
On Saturday, 22 October 2022 at 22:25:16 UTC+2 dple...@google.com wrote: > that the above function is much easier to read and much faster to write True but in my opinion not relevant because: 1. Time to write a function is almost negligible compare to its time needed for maintenance, rewrites,

[go-nuts] Re: Triggering go:generate via go build/install?

2022-08-08 Thread Volker Dobler
Executing code during build is a 100% no-go from a security perspective. Especially arbitrary 3rd party code. So let me rephrase it: > One of the big advantages of Go's build systems is that running > generators is **not** automated. V On Monday, 8 August 2022 at 12:34:43 UTC+2

[go-nuts] Re: Query regarding net/http/cookiejar: Cookies() method and Expiry/MaxAge

2022-06-30 Thread Volker Dobler
On Thursday, 30 June 2022 at 00:31:29 UTC+2 amits wrote: > Currently the Cookies() method as explained at > https://pkg.go.dev/net/http/cookiejar#Jar.Cookies only adds the Name and > Value of the cookies and strips out the MaxAge and Expires field (and all > other fields). Presumably, as I can

[go-nuts] Re: Installing a package with an associated command

2022-05-25 Thread Volker Dobler
If you want the command to be installed: Why don't you install _the_ _command_ with go install https://github.com/chmike/clog/cmd/clogClr@latest ? (Note that there is no need to install the package.) V. On Wednesday, 25 May 2022 at 08:13:58 UTC+2 christoph...@gmail.com wrote: > I have a

[go-nuts] Re: Pointer to a pointer

2022-03-09 Thread Volker Dobler
> > > Does anyone know what the upper bound on this could be? > > Yes, I do: math.MaxUint64 ! The nice thing about upper bounds is that they can be larger than the least upper bound :-) V. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

[go-nuts] Re: Why don't we have to use 'std' as the module prefix for packages from the standard library?

2021-09-03 Thread Volker Dobler
On Friday, 3 September 2021 at 02:18:54 UTC+2 Connor Kuehl wrote: > But this whole time as I've been learning the language, the standard > packages can be imported without any explicit prefix: > > import "fmt" > > and I found a go.mod in my Go distribution's standard library [1], so > that

[go-nuts] Re: Questions about documentation of Go standard library

2021-08-29 Thread Volker Dobler
On Sunday, 29 August 2021 at 09:47:09 UTC+2 Brian Candler wrote: > To be pedantic, Len(9) == 4 > :-) > Me stupid :-( -- 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

[go-nuts] Re: Questions about documentation of Go standard library

2021-08-26 Thread Volker Dobler
On Thursday, 26 August 2021 at 22:17:55 UTC+2 kziem...@gmail.com wrote: > Another topic. I needed to check package "math/bits" (learning about Go > can lead us in such places quite fast) and I'm confused about function > "Len(x uint) int". In its description we have ( >

[go-nuts] Re: Questions about documentation of Go standard library

2021-08-26 Thread Volker Dobler
On Thursday, 26 August 2021 at 13:27:01 UTC+2 kziem...@gmail.com wrote: > Line "early regular expression implementations used and that POSIX > specifies" is a bit confusing to me. I guess it can mean "old > implementations Go regexp package", This guess is wrong. Go's regexp package did and

[go-nuts] Re: How to set version number of the package imported locally

2021-07-28 Thread Volker Dobler
1. It's a made up dummy 2. You cannot and you need not. V. On Wednesday, 28 July 2021 at 18:02:03 UTC+2 isma...@gmail.com wrote: > My `go.mod` file looks like > ``` > module school > go 1.13 > replace sample.com/math => ../math > ``` > > When I run `go run school.go` the `go.mod` file

Re: [go-nuts] Re: Stack growing is inefficient

2021-07-01 Thread Volker Dobler
Note that the compiler should generate efficient code for common, typical, real-world code. Optimising the compiler to generate the most efficient code for pathological code can be a waste of time, both for the compiler writers and for the users waiting longer for their "normal" code to be

[go-nuts] Re: How is golang web applications for seo

2021-06-02 Thread Volker Dobler
On Tuesday, 1 June 2021 at 18:39:48 UTC+2 beeke...@gmail.com wrote: > How are golang web applications on a scale of 1 to 10 for seo rankings? They range from 1 to 10 depending on how they are implemented. SEO ranking is not influenced by the language you write your "web application" in. V.

[go-nuts] Re: Modules... why it has to be so painfull?

2021-04-09 Thread Volker Dobler
On Friday, 9 April 2021 at 17:38:12 UTC+2 gonutz wrote: > A replace in the go.mod file is of no help here because I still have to > specify a require with a concrete version or commit hash for the library. > Why do you think so? Replace with your local filesystem path of the library requires

[go-nuts] Re: go mod vendor, description, how?

2021-04-06 Thread Volker Dobler
Probably you are overthinking it. Start like this go mod init me.nil/project It doesn't matter whether you want to publish your project or not you must start with a module and a proper name including a dot and a slash doesn't harm and avoids several problems. Of course you also could name it

[go-nuts] Re: Go modules: why no_version != latest ?

2021-03-03 Thread Volker Dobler
On Wednesday, 3 March 2021 at 08:35:49 UTC+1 rolf...@gmail.com wrote: > In my not painless transition from GOPATH to modules, I would like to > understand why import paths without a version are not equal to 'latest', > which is what happens in many other contexts: no version specified, use >

Re: [go-nuts] Differences between go1.16 and go1.15 ?

2021-02-25 Thread Volker Dobler
On Thu, 25 Feb 2021 at 09:08, Paul Förster wrote: > Hi Volker, > > > On 25. Feb, 2021, at 08:46, Volker Dobler > wrote: > > > > I think there is a major problem with "go run main.go": It creates > > a _false mental model_ of how Go code is built a

Re: [go-nuts] Re: Differences between go1.16 and go1.15 ?

2021-02-24 Thread Volker Dobler
On Wed, 24 Feb 2021 at 20:00, Ian Lance Taylor wrote: > On Sat, Feb 20, 2021 at 8:26 AM Volker Dobler > wrote: > > > > 1. Do not use go run main.go. Never! > > I want to point out that this is too strong. There are perfectly good > reasons to use "go run main

Re: [go-nuts] promoted methods confusion

2021-02-23 Thread Volker Dobler
On Tuesday, 23 February 2021 at 07:01:27 UTC+1 Henry wrote: > I think the problem is that people try to use embedding in place of > inheritance. [...] Embedding shares many similarities to inheritance The first part is a real common problem but I have to admit I do not understand where the

[go-nuts] Re: Few questions regarding Generics

2021-02-22 Thread Volker Dobler
On Monday, 22 February 2021 at 15:03:53 UTC+1 Khosrow Afroozeh wrote: > type List[T any] []T > > 1. The current go2go implementation does not allow one to do this: > > func ToList[T any](v []T) List[T] { > return List(v) > } > > with the error: List(v) is not a type > > Is this a bug,

[go-nuts] Re: Differences between go1.16 and go1.15 ?

2021-02-20 Thread Volker Dobler
(premature send, sorry) 4. Your matrix multiplication is just a few CPU instructions, it is hard to measure something tiny reliable. So use larger matrixes. 5. You are benchmarking also how fast you can format and output the results to stdout. This might or might not be intentional but probably

[go-nuts] Re: Differences between go1.16 and go1.15 ?

2021-02-20 Thread Volker Dobler
1. Do not use go run main.go. Never! 2. Do not run your code with the much less problematic go run because go run compiles and executes your code and the time needed to compile it will ruin all benchmarks. 3. Always use the benchmarking infrastructure built into go test and and package testing.

Re: [go-nuts] Error handling

2021-02-15 Thread Volker Dobler
I think there is strong consensus, that the current style of error handling is currently the best option. Nobody has been able to come up with something better (really better, not just more comfortable while ignoring hefty drawbacks). It is true that a loud minority seems to miss exceptions to

[go-nuts] Re: Contributing to golang based project on github - collaboration best practice

2021-02-02 Thread Volker Dobler
You either have to use the "replace" directive in go.mod, or: Do not work on the fork. Do your work on a plain _clone_ of the repo (which works without "replace"ing dependencies). To create a Github PR: git push to your fork (add it as an additional git remote) and create the PR. The "fork" is

[go-nuts] Re: Virtual time for testing

2021-01-29 Thread Volker Dobler
One way to do this is have an internal implementation like func generatorImpl(sleep func(time.Duration)) <-chan int and func generator just calls that one with time.Sleep. Tests are done against generatorImpl where you know have detailed control of how much (typically none) time is actually slept.

Re: [go-nuts] Generics - please provide real life problems

2021-01-04 Thread Volker Dobler
On Sunday, 3 January 2021 at 18:43:22 UTC+1 ren...@ix.netcom.com wrote: > I do believe (hope) David was kidding. Anonymous product types (and > similar constructs) are the root of all evil. > Yes, you need dependent product types. Especially anonymous ones. (Just be be clear: I _am_ kidding.)

[go-nuts] Re: 1.16 beta 1 - Getting an error trying to use the "embed" package

2020-12-18 Thread Volker Dobler
Use import _ "embed" // note the _ Your code does not use package embed. A comment does not qualify as usage. As yous must import it for //go:embed comments to work you have to use a "side-effects-only"-import. V. On Friday, 18 December 2020 at 13:38:10 UTC+1 amits...@gmail.com wrote: >

[go-nuts] Re: New methods on imported structs: how do I do this with complex external structs

2020-10-13 Thread Volker Dobler
You cannot do this. 1. You cannot add methods to imported types. 2. Embedding is not inheritance. (While sometimes things which are often done via inheritance can be done with embedding too embedding simply is not inheritance and leads to a totally different type.) 3. Go's slices (and arrays)

[go-nuts] Re: method resolution order

2020-09-16 Thread Volker Dobler
On Wednesday, 16 September 2020 at 10:51:27 UTC+2 stephan...@gmail.com wrote: > Assume a public interface I with two methods NotInS and M whereas NotInS > is calling M. An implementation i of I which implements NotInS and M as > well as a specialization s of i which only implements M. Finally

[go-nuts] Re: Proposal: auto return String instead of []byte if requested

2020-09-11 Thread Volker Dobler
Please no. This is just begging for problems. A simple type conversion is 1 (one!) line and pretty clear. Once you open this can of worms someone would like to have a []rune and then automatic conversions from int32 to int and 6 month later you have a JavaScript like nonsense language just

[go-nuts] Re: Interface definition as type alias

2020-09-08 Thread Volker Dobler
In practice you never declare the same interface twice switch from one to the other. Why would anybody declare his own ResonseWriter interface if net/http.ResponseWriter exists? So yes: Using a type alias has advantages, but no, this advantage is never realized because neither the alias nor the

Re: [go-nuts] Re: How to know if interface{} data is nil w/o reflecting?

2020-08-27 Thread Volker Dobler
On Thursday, 27 August 2020 11:39:11 UTC+2, targe...@gmail.com wrote: > > To me, if `x == nil` and then `y != nil` after `y = x` is much more > confusing. > This can happen only if x and y have different types. And for different types this is pretty normal as you can have x == 0.2 //

Re: [go-nuts] [ generics] Moving forward with the generics design draft

2020-08-22 Thread Volker Dobler
On Friday, 21 August 2020 20:15:46 UTC+2, burak serdar wrote: > > [...] > I don't see why anybody would find it attractive as a return type. People > don't use the empty interface because they like it so much, but because Go > doesn't have parametric polymorphism / "generics" yet. There are

Re: [go-nuts] Re: module confusion

2020-08-14 Thread Volker Dobler
On Friday, 14 August 2020 20:39:37 UTC+2, K Richard Pixley wrote: > > Isn't this the default location? I just untarred the distribution... > No. There is a reason https://golang.org/doc/install#install states to do tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz V. -- You received this

Re: [go-nuts] where is go code generate type info?

2020-08-14 Thread Volker Dobler
On Friday, 14 August 2020 13:00:19 UTC+2, xie cui wrote: > > the return instance of reflect.TypeOf(some object) should be generate by > compiler, the type info which could be in elf files. i want to known where > compiler generate it. > Maybe this is the reason for your confusion. Your

Re: [go-nuts] where is go code generate type info?

2020-08-14 Thread Volker Dobler
n Friday, August 14, 2020 at 1:32:25 PM UTC+8 Volker Dobler wrote: > >> The value returned by reflect.TypeOf is not computed during >> compile time but during run time. The code for package >> reflect is generated by the compiler during compile time >> but thi

Re: [go-nuts] where is go code generate type info?

2020-08-13 Thread Volker Dobler
The value returned by reflect.TypeOf is not computed during compile time but during run time. The code for package reflect is generated by the compiler during compile time but this is not interesting to understand reflection at all as it is the same code generation like for lets say net/http. The

Re: [go-nuts] import a file

2020-07-31 Thread Volker Dobler
On Friday, 31 July 2020 04:55:50 UTC+2, jules wrote: > > Modules are a great idea and I want to use them, but I can't get it to > compile > a "hello golang" program even: > > === > $ ls /home/jfields/go/src/jsonstuff > typestuff.go > $ go mod init src > go: creating new

Re: [go-nuts] import a file

2020-07-30 Thread Volker Dobler
The best advice is: Read How to Write Go Code https://golang.org/doc/code.html and stick to it. Yes, modules are the thing to be used 1. But naming a module "src" is begging for trouble. Name your module either something like julesgocode.org/firsttry or maybe github.com//firsttry 2. If your

[go-nuts] Re: Generics and parentheses

2020-07-21 Thread Volker Dobler
On Tuesday, 21 July 2020 05:06:11 UTC+2, Bit0r Mack wrote: > > > Among them, is the most convenient to input, > because < and? Are very close on the keyboard, so you can input quickly > < and ? on my keyboard are almost the most distant keys (_ and ° having the same distance and < and ^ being

[go-nuts] Re: run golang cpu profile for 5mins but only got 1.64mins (32.69%) samples

2020-07-01 Thread Volker Dobler
On Tuesday, 30 June 2020 18:16:54 UTC+2, lqiy...@gmail.com wrote: > > $ go version > go version go1.13.10 > > In the container, the golang process used 100% of the CPU. When I took a > 5minutes CPU profile, the result shows that only 1.64mins (32.69%) samples > are returned. Is it normal? > > go

[go-nuts] Re: can a sub-directory package of a module be imported?

2020-06-30 Thread Volker Dobler
On Tuesday, 30 June 2020 06:34:48 UTC+2, Jason E. Aten wrote: > > I have a files laid out like this (OSX): > > ~/go/src/github.com/user/fish/api/client/wanda.go > > ~/go/src/github.com/user/fish/go.mod with first line "module > github.com/liked/movies/v2" > >

[go-nuts] Re: Expanding variables and fmt.Printf() issue

2020-06-29 Thread Volker Dobler
> If I use append() instead of Printf(), this expanding of the host > variables just works out. Is this a compiler bug in the case of the > fmt.Printf() ? > I doubt that append("%v.%v.%v.%v\n", host[0:4]...) does compile. V. -- You received this message because you are subscribed to

[go-nuts] Re: [generics] Replace () with <> or other character

2020-06-18 Thread Volker Dobler
On Thursday, 18 June 2020 10:15:16 UTC+2, Nathanael Curin wrote: > > An argument for this is also that (all ?) languages that use generics use > <>. It might make learning just easier for new Go developers that have > experience from generics-compatible languages. > And an argument against

[go-nuts] Re: help understanding weird Benchmark results

2020-05-19 Thread Volker Dobler
You are supposed to run the loop b.N times, not some fixed constant. Also make sure the compiler doesn't optimize away the whole function. V. On Tuesday, 19 May 2020 18:20:43 UTC+2, Warren Bare wrote: > > Hi Folks, > > I'm getting weird results from Benchmark. Maybe someone can help me >

[go-nuts] Re: How to work with multiple environment like dev, test, staging, prod in golang ?

2020-05-17 Thread Volker Dobler
Go, the language and the std tooling has no predefined way of doing this. Do whatever fits your need. V. On Sunday, 17 May 2020 19:19:23 UTC+2, Shishira Pradhan wrote: > > Hi All, > > i'm a java developer, currently working on golang. In springboot, we have > configuration like port, database

[go-nuts] Re: interface vs functions for mocking

2020-05-11 Thread Volker Dobler
On Saturday, 9 May 2020 09:57:50 UTC+2, Amarjeet Anand wrote: > > While writing unit test, what should be the preferred way to mock an > external(database, http...) call, *function based approach* or *interface > based approach?* > > I don't understand when to use function way and when to use

[go-nuts] Re: func before function

2020-04-28 Thread Volker Dobler
On Monday, 27 April 2020 18:46:20 UTC+2, valen...@gmail.com wrote: > > Why is it necessary to write func in go before declaring a function; if in > C, when parsing a function, there is no such need? > Why "func sum(a, b int) int {...}" can't be "sum(a, b int) int {...}" > Of course it could be

[go-nuts] Re: wording in Go tour, methods/19

2020-04-16 Thread Volker Dobler
On Wednesday, 15 April 2020 17:58:11 UTC+2, Marvin Renich wrote: > > In the Go tour at https://tour.golang.org/methods/19 it says > > The error type is a built-in interface similar to fmt.Stringer: > > The words closest to "similar to" are "built-in interface", implying > that the way error

[go-nuts] Re: go run requires internet connection?

2020-04-09 Thread Volker Dobler
On Wednesday, 8 April 2020 18:17:36 UTC+2, Tanmay Das wrote: > > Is this behavior expected? If it is, why did the go authors make such a > decision? I mean making the internet connectivity a dependency for the > execution of a program sounds counter-productive to me, honestly. :( > Well, go run

[go-nuts] Re: How to read http.Response from http.Request

2020-03-18 Thread Volker Dobler
That _is_ the correct way iff req is not nil. Check your errors first. V. On Wednesday, 18 March 2020 06:22:07 UTC+1, Alexander Mills wrote: > > > hey all I am trying to read the Response from http.Request like so: > > func (ctr *Controller) Login(c *common.CPContext, req *http.Request, res >

Re: [go-nuts] Re: Mem-Leak in Go method

2020-03-16 Thread Volker Dobler
On Monday, 16 March 2020 14:25:52 UTC+1, Nitish Saboo wrote: > > Hi, > > I upgraded the go version and compiled the binary against go version 'go > version go1.12.4 linux/amd64'. > I ran the program for some time. I made almost 30-40 calls to the method > Load_Pattern_Db(). > The program starts

Re: [go-nuts] Re: Where is the version number for a golang module declared?

2020-03-12 Thread Volker Dobler
The go tool works well if you use package import path as arguments. On Wednesday, 11 March 2020 20:49:53 UTC+1, Dean Schulze wrote: > > Well here's what I get in my module with a single directory with a single > file with a single package called lib: > To be concrete let the module name be

[go-nuts] Re: Memory leak or GC feature ?

2020-03-06 Thread Volker Dobler
This is normal behaviour and not a leak. Nothing is leaking in your code (and it is generally hard to leak RAM). The allocations will be reclaimed. V. On Friday, 6 March 2020 14:11:37 UTC+1, Christophe Meessen wrote: > > I wanted to check my program for go routine and memory leaks. In doing so

[go-nuts] Re: Modules and cross-compilation

2020-02-26 Thread Volker Dobler
On Wednesday, 26 February 2020 20:53:52 UTC+1, geoff.j...@gmail.com wrote: > > This baffles me: > > > $ go build foo.com/foobar > can't load package: package foo.com/foobar: cannot find module providing > package foo.com/foobar > > You simply cannot build a module. Only packages can be built. and

[go-nuts] Re: Directly assign map[string]int to map[string]interface{}?

2020-02-23 Thread Volker Dobler
It boils down to the meaning of interface{}. interface{} means interface{} and _not_ "any type". While you can assign anything to a variable of type interface{} this does not mean that a variable of type interface{} _is_ "any type". There is no "any type" type in Go. V. On Sunday, 23 February

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-19 Thread Volker Dobler
On Wednesday, 19 February 2020 11:59:33 UTC+1, klos...@gmail.com wrote: > > [...] > But if you create wood houses for people, you don't even think of using a > hammer! You will use a much more reliable tool. Or if you use it, it will > probably be the best hammer in the market, with a perfect

Re: [go-nuts] Question about the zero-value design: Why pointers zero value is not the zero value of what they points to?

2020-02-18 Thread Volker Dobler
On Tuesday, 18 February 2020 12:44:16 UTC+1, klos...@gmail.com wrote: > > Well, other languages use the optional/maybe type. It handles sentinel > values pretty well and I don't think they bring new kind of bugs (while > they remove the nil-pointer related bugs). > That is the market claim.

[go-nuts] Re: Go Module and Build Tag

2020-01-29 Thread Volker Dobler
Build tags are per build, not per package. So no, you cannot. V. On Wednesday, 29 January 2020 04:03:15 UTC+1, Henry wrote: > > Hi, > > I wonder whether it is possible to specify a dependency's build tags in go > module. Let's say that Project A depends on Library B. Library B has > optional

[go-nuts] Re: Is it considered to separate runtime and cmd/compile irrelevant standard libraries out from the core language repo and hosted in a different module, eg. std?

2020-01-27 Thread Volker Dobler
On Monday, 27 January 2020 12:27:35 UTC+1, changkun wrote: > > Dear golang-nuts, > > As https://github.com/golang/go/issues/27151, > https://github.com/golang/go/issues/6853 and many relevant issues > discussed, Go download is huge. > Neither of these issues benefits from splitting the stdlib

[go-nuts] Re: How to set-up go env properly

2020-01-22 Thread Volker Dobler
You either need the full import path of the package to test or a simple $ go test V. On Wednesday, 22 January 2020 10:52:41 UTC+1, pc wrote: > > Hello, > >I am setting up my go project directories to test. I have set up like > bellow > and my GOPATH is testexercise. Application builds

[go-nuts] Re: Code Coverage for executable written in GoLang

2020-01-09 Thread Volker Dobler
On Thursday, 9 January 2020 16:39:40 UTC+1, rk303...@gmail.com wrote: > > I have one exe file which contains code written in the Go language. I > don’t have a source code for this. Is there a tool or technique by which I > can determine the code Coverage for this executable [?] > No, for

[go-nuts] Re: Go modules and project-local imports.

2019-12-04 Thread Volker Dobler
On Tuesday, 3 December 2019 18:36:49 UTC+1, Bruno Albuquerque wrote: > > It will fail because it will say it can not find "project" > > If I add a proper go.mod file in the example directory, then it works but > it actually pulls a version of project from the vcs (this is, of course, > assuming

[go-nuts] Re: What is the correct way to access/modify slice elements concurrently

2019-11-08 Thread Volker Dobler
On Friday, 8 November 2019 05:47:03 UTC+1, Kasun Vithanage wrote: > > What is the best approach? > There is no single "best approach". If two goroutines A and B access two different indices iA and iB you do not need any synchronisation between them. If iA==iB you need to protect reads from

[go-nuts] Re: GO Mod (modules) for dummies. Please help.

2019-10-24 Thread Volker Dobler
Hi I think one of the main struggles stems from "dependency" having two technical meanings: a) If a package a imports a package b then a depends on b. This is a priori agnostic to versions. This type of dependency is expressed by a simple import "import/path/of/b" in a's source

[go-nuts] Re: Forking gotk3 not working?

2019-09-25 Thread Volker Dobler
In general: You cannot use a Github Fork of a Go module. A fork creates a new package/module with different package/module names and in general (trivial cases _do_ work) you cannot even build it. What you should do: - Fork the repo but do not work on your fork! - Clone the repo you want to work

[go-nuts] Re: When doing "type X Y", is it a type alias or type redefinition or type adapter or something else?

2019-08-13 Thread Volker Dobler
On Tuesday, 13 August 2019 17:03:36 UTC+2, jochen...@gmx.de wrote: > > type X Y is a type declaration, you have to cast between the types > type X=Y is a type alias, where X can be used as Y without casting > There are no type cast in Go. Only type conversions. V. -- You received this message

Re: [go-nuts] Re: When doing "type X Y", is it a type alias or type redefinition or type adapter or something else?

2019-08-13 Thread Volker Dobler
On Tuesday, 13 August 2019 09:43:05 UTC+2, Jan Mercl wrote: > > On Tue, Aug 13, 2019 at 9:24 AM Volker Dobler > > wrote: > > > Yes, of course. It declares a new named type X, the underlying > > type is Y which can be some predeclared type like int, some > >

[go-nuts] Re: When doing "type X Y", is it a type alias or type redefinition or type adapter or something else?

2019-08-13 Thread Volker Dobler
On Tuesday, 13 August 2019 08:10:56 UTC+2, Sathish VJ wrote: > > So doing *type X Y* is just a type declaration then? > Yes, of course. It declares a new named type X, the underlying type is Y which can be some predeclared type like int, some other named declared type (like MyFooType) or a "type

Re: [go-nuts] Re: Go Language Survey

2019-06-12 Thread Volker Dobler
gt;> 253563 | 5.3980% | : >> 155297 | 3.3061% | := >> >> *138465 | 2.9478% | [138465 | 2.9478% | ] * >> 78567 | 1.6726% | != >> 72007 | 1.5329% | * >> >> On Wed, Jun 12, 2019 at 1:51 PM Volker Dobler > > wrote: >

[go-nuts] Re: Go Language Survey

2019-06-12 Thread Volker Dobler
Cool work! What I found most astonishing on a first look: Not all parentheses ( are closed: 4 ) seem to be missing?? For { 5 are unclosed while there is one more ] than [ ? Are you parsing testfiles with deliberate errors? V. On Wednesday, 12 June 2019 15:08:44 UTC+2, Michael Jones wrote: > >

[go-nuts] Re: There is definitely a race condition, why it can't be detected by race condition detector?

2019-05-01 Thread Volker Dobler
I think this boils down to: Your code is _missing_ the relevant CAS from the original code. V. On Tuesday, 30 April 2019 05:18:39 UTC+2, jacki...@gmail.com wrote: > > On line 85 in > https://github.com/golang/go/blob/release-branch.go1.12/src/sync/mutex.go , > the code " old := m.state " is

Re: [go-nuts] the Dominance of English in Programming Languages

2019-04-29 Thread Volker Dobler
The number of keywords and their "origin language" does not matter much, that is something we probably can all agree to, especially with the very few kewords in Go. But if you try to teach 9 or 10 year old kids to program you cannot do this in the language alone, you need at least to import fmt.

[go-nuts] Re: go test cover on other platforms

2019-04-11 Thread Volker Dobler
On Thursday, 11 April 2019 11:08:16 UTC+2, hui zhang wrote: > > I am developing go on mac > but my test environment is on linux. > > Can I build a bin like > GOOS=linux GOARCH=amd64 go test -c && ./sum.test > > and do test on linux , and get a coverage report ? > how? > > Need install go

Re: [go-nuts] A value copy will occur when executing for range xxx?

2019-04-04 Thread Volker Dobler
On Thursday, 4 April 2019 08:49:48 UTC+2, mount...@gmail.com wrote: > > hehe, thanks, so if i want understand deeply, need to look up gc code? > No, that is not necessary for basics like this question here. The compiler implements the language spec and the spec describes how the language works

[go-nuts] Re: efficient random float32 number generator?

2019-02-26 Thread Volker Dobler
On Monday, 25 February 2019 23:01:39 UTC+1, DrGo wrote: > > what is the fastest possible algorithm to generate a float32 > pseudo-random number in [0.0,1.0)? > need to generate billions of numbers. Statistical performance and security > (and even space) are not a priority. > If all you care is

Re: [go-nuts] Parsing date with Timezone doesn't return UTC

2019-02-13 Thread Volker Dobler
There are several issues here. 1. If you use fmt.Println to display a time.Time it will generate a human readable output but this does _not_ accurately reflect all technical internal details of a time.Time. It is often a bad idea to simply dump stuff with fmt.Println. 2. time.Parse and timezones

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

2019-02-07 Thread Volker Dobler
> > The UTF8 encoding of that codepoint is three bytes. So the rune will > still occupy 4 bytes, even if the last byte holds no data? > A rune has nothing to do with UTF-8. A rune stores the codepoint which is totally independent of any encoding (like UTF-8, UTF-16, UTF-23, EBCDIC, whatnot).

[go-nuts] Re: Why is "v" prefix for VCS tag required for ?

2019-02-04 Thread Volker Dobler
Well, it is good to have exactly one valid format. With two options like "vN.M.L" and "N.M.L" confusion starts to spread and why not allow a capital "V" too and a "ú" too for "útgáfa" and "r" for "release" should be allowed too. If you start with two options you open up a flood of endless

Re: [go-nuts] Re: What does "nil implay?

2019-01-23 Thread Volker Dobler
On Wednesday, 23 January 2019 13:31:13 UTC+1, Victor Giordano wrote: > > You wrote > > >> All nil values are perfectly defined: they are the zero value of the >> particular type. > > > As i see things the nil is the *default value* for the pointers. If you > want to call it "zero value" to

[go-nuts] Re: go language sensitive editor?

2018-11-22 Thread Volker Dobler
As emacs has not been recommended yet: Emacs! V. On Tuesday, 20 November 2018 21:52:11 UTC+1, Pat Farrell wrote: > > I know, this is both a FAQ and an unanswerable question. I'm an old > programmer who has used nearly every editor known to man. I am not a fan of > whole-universe IDEs, but can

[go-nuts] Re: Force pointer at compile time to interface{} parameter

2018-11-19 Thread Volker Dobler
> Is there a way to force "SomeFunction" to take pointers only at compile time? No, sorry. V. -- 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] About source folder organization

2018-11-15 Thread Volker Dobler
Ooops: This should read It simply does *NOT* influence the one and only package rule. On Thursday, 15 November 2018 09:04:01 UTC+1, Volker Dobler wrote: > > My opinion on this: You are overthinking it. A lot. > > Let's start simple. Cyclic dependencies between packages >

Re: [go-nuts] About source folder organization

2018-11-15 Thread Volker Dobler
My opinion on this: You are overthinking it. A lot. Let's start simple. Cyclic dependencies between packages are disallowed and whatever you do you packages must not for an import cycle. This is the only hard rule. Note that this rule is totally decoupled from the filesystem layout of your

[go-nuts] Re: invalid months and years in time package

2018-10-23 Thread Volker Dobler
Why is year -1 invalid and what is an "invalid" month given that 13==1 in Z_12? V. On Tuesday, 23 October 2018 16:01:00 UTC+2, Taras D wrote: > > Hi, > > I was surprised to find the following worked without any reported errors: > > t1 := time.Date(-1, 1, 10, 23, 0, 0, 0, time.UTC) // invalid

  1   2   >