[go-nuts] time.Now takes ~3758 ns/op, is that normal?
Hello, I downloaded your gist and these are my results: ~/.Trash$ $ curl -s -O https://gist.githubusercontent.com/reinit/82608ab20e5aac3bd3c1eb5a8f78d23c/raw/bbc6fdb1ad0f137a66a986fe2af931ea477b5625/time_now_test.go ; go version ; go test -bench . go version go1.10.2 darwin/amd64 goos: darwin goarch: amd64 BenchmarkTimeNow-4 1 15.6 ns/op PASS ok _/Users/USERNAME/.Trash 1.587s Modellname: MacBook Pro Modell-Identifizierung: MacBookPro9,2 Prozessortyp: Intel Core i5 Prozessorgeschwindigkeit: 2,5 GHz Anzahl der Prozessoren: 1 Gesamtanzahl der Kerne: 2 L2-Cache (pro Kern): 256 KB L3-Cache: 3 MB Speicher: 16 GB Systemversion: macOS 10.13.4 (17E202) Kernel-Version: Darwin 17.5.0 Regards Mirko -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Why doesn't this select statement timeout?
That is an excellent example. Thanks! On Thursday, May 24, 2018 at 8:26:36 AM UTC-7, alex@gmail.com wrote: > > No, not the entire case statements, only the statements on the right of > the "<-" > > btw if you run it out of the playground (which makes concurrency more > deterministic) > You would get timeout sometimes and nil sometimes > > Also maybe this example would help you understand what's going on. > https://play.golang.org/p/DokMlHtdzi7 > > On Thursday, 24 May 2018 16:58:20 UTC+8, gopher...@gmail.com wrote: >> >> Thanks for the reply. >> >> So you're saying that all case statements are evaluated first before a >> choice is made. >> Which means that the full request/response must complete even if the >> timeout case finishes first. >> >> If I swap the cases, now I consistently get a `timeout`. >> All cases are run to completion, so the full request/response occurs. >> Whats the reason for selecting the timeout? shouldn't it be pseudo-random? >> https://play.golang.org/p/M-7rMPJxOWq >> >> How should the done channel be setup to get this example working properly? >> >> >> >> On Tuesday, May 22, 2018 at 5:29:43 PM UTC-7, alex@gmail.com wrote: >>> >>> https://golang.org/ref/spec#Select_statements >>> >>> Execution of a "select" statement proceeds in several steps: 1. For all the cases in the statement, the channel operands of receive operations and the channel and right-hand-side expressions of send statements are evaluated exactly once, in source order, upon entering the "select" statement. The result is a set of channels to receive from or send to, and the corresponding values to send. Any side effects in that evaluation will occur irrespective of which (if any) communication operation is selected to proceed. Expressions on the left-hand side of a RecvStmt with a short variable declaration or assignment are not yet evaluated. 2. If one or more of the communications can proceed, a single one that can proceed is chosen via a uniform pseudo-random selection. Otherwise, if there is a default case, that case is chosen. If there is no default case, the "select" statement blocks until at least one of the communications can proceed. 3. Unless the selected case is the default case, the respective communication operation is executed. 4. If the selected case is a RecvStmt with a short variable declaration or an assignment, the left-hand side expressions are evaluated and the received value (or values) are assigned. 5. The statement list of the selected case is executed. >>> So it evaluates all your function calls before doing the select in the >>> order they appear in single threadeddly. >>> >>> On Wednesday, 23 May 2018 07:29:59 UTC+8, ag wrote: This is interesting and I still don't get why it's not working. I modified the code a bit and expected it to immediately break out of select but it still waits for http calls to finish https://play.golang.org/p/z1mmqpQtOre package main import ( "errors" "fmt" "net/http" "net/http/httptest" "time" ) func main() { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { time.Sleep(1 * time.Second) w.WriteHeader(http.StatusOK) })) defer ts.Close() req, _ := http.NewRequest(http.MethodGet, ts.URL, nil) f := func(r *http.Request, n int) error { fmt.Println("Making the http call ", n) _, err := http.DefaultClient.Do(r) return err } ch := make(chan error, 1) timeout := 1 * time.Millisecond select { case ch <- errors.New("immediate timeout"): case ch <- f(req, 1): case ch <- f(req, 2): case <-time.After(timeout): fmt.Println("Timeout being called") ch <- errors.New("timeout") } err1 := <-ch fmt.Println("Received first error", err1) close(ch) // Output: // Making the http call 1 // Making the http call 2 // Received first error immediate timeout } On Monday, May 21, 2018 at 10:25:08 PM UTC-7, Burak Serdar wrote: > > On Mon, May 21, 2018 at 12:13 PM, wrote: > > timeout := 1 * time.Millisecond > > select { > > case ch <-f(req): > > case <-time.After(timeout): > > ch <- errors.New("timeout") > > } > > The instant 'select' is evaluated, ch is writable. Also time.After() > is called, and returns a channel that will be ready to be read in a > millisecond, i.e. not readable immediately. So it'll write to ch, and > will never timeout. > > To do what you described, you need to run the request piece in a > gorou
[go-nuts] New Embedded Document Database (Alpha)
I am developing an embedded document/json database (based on badger key-value store). Queries are performed using predefined views, very much like views in CouchDB, except that they get updated inside same transaction, so they are consistent - vs Eventual Consistent. At alpha stages it is, and any feedback/PRs are most welcome! https://github.com/dc0d/dockage -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] [ANN] sqlx for cassandra gocqlx v1.0.0 released
GoCQLX is a general purpose extensions to golang's Cassandra driver gocql. With gocqlx you can bind query parameters from maps and structs, use named query parameters (:identifier) and scan query results into structs and slices. It comes with a fluent and flexible CQL query builder and a database migrations module. https://github.com/scylladb/gocqlx -- If you enjoy hacking database drivers and building tools come [join us](https://www.scylladb.com/company/careers/). -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Freeing memory of a cgo library
Looks like you are on windows. I have worked a lot with windows, C/C++ and go, but never actually built a go dll. But, since no one else has picked this up, maybe I can help. 1. I'm not sure what "the cgo" library means here? Do you have this: cpp<->go(dll)<->c(cgo)? Or something else. 2. How is the memory in question allocated? What is the line of code that allocates it, and where does it reside in the chain above? On Thursday, May 24, 2018 at 8:35:07 AM UTC-4, Liron Levy wrote: > > Hey guys, > > I'm in a bit of a mass, I can not see how I'm getting out of... > What do I got: > * A library I built using cgo. > * A cpp app using this library (dll). > > What do I do: > I try to free memory I have allocated in the cgo library in the cpp app. > > What Tools do I use: > To build the library (dll) I use cgo, then creating a stub lib using the > VS cmd. > I use visual studio 2017 to compile the app (with /MD) option. > > What do I get: > Critical error detected c374 > > As far as I can see, this is a result of me freeing data which was > allocated in the dll libarary. > I will note that this does not happen if I create a test app and compile > it with gcc. > > Unfortunately, I can not avoid using VS as I am working with some CUDA > stuff which like VS better :/ > > Thanks for taking the time to read\help, > Liron > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Freeing memory of a cgo library
Hey Jake, First if all thanks for the willing to help. Cgo is the built-in tool in go of building c libraries (see: https://golang.org/cmd/cgo/) What I basically do is that I have a go code, which i build into c library (dll), i.e, i insert the go code onto the cgo mechine then get .h and .dll on the otherside. The memory is allocated inside the .dll using C.malloc (which is basically c malloc), and i try to free it inside the cpp file which is linked to this dll. If i build a function inside the go code to free a recived pointer, which will end up in the dll, then the problem is avoided. That being said, due to the fact that I have quite a few callbacks and a large data transfer between the dll and my app i would like to keep it simple and not have to use a third function to free the mallocs, as it is also a problem if it happens the other way around, i.e., if i allocate memory in the app and try to free it inside the library. Sorry if im unclear i tried to explsin it the best as i can. Ps yes i do use windiws, a side remark is that if i use gcc this does not happen. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] go tool trace: --> filtering/modifying
Hey, in the end I've used opencensus which has the same features as go's spans, but it's designed for distributed tracing. I already have multiple backend support, which supports more advanced filtering options than chrome://tracings's catapult viewer. Thanks, Neven Miculinić On Tue, 8 May 2018 at 08:42, Tarmigan wrote: > In addition to the documentation that Hana pointed to, she also just > gave a great talk that included a walk through of the new features and > how they may be used to view high latency events: > https://www.youtube.com/watch?v=FJQjUueBJ2A > > It's worth watching if you are interested in tracing and latency, and > I'm looking forward to trying the new APIs soon. > > > On Mon, May 7, 2018 at 1:31 PM, Hyang-Ah Hana Kim > wrote: > > Have you tried the new annotation api in the tip? > > tip.golang.org/pkg/runtime/trace? > > Please see if annotating in the source code with Region or Task would > work > > for your case. > > > > > > On Wed, May 2, 2018 at 8:59 AM, wrote: > >> > >> High level goal: > >> > >> I have an application with significant number of goroutine experiencing > >> latency issues. I want to detect and dissect where those issues arise > and > >> determine how can I fix them. For that I’ve use go tool trace > >> > >> Middle-level features: > >> > >> I want to filter event in the catapult viewer (( I cannot find > >> documentation how to do it, and JS ecosystem I’m not really proficient > in )) > > > > > > What kind of filtering do you want to perform? > >> > >> Since I’m using errgroups, event names are all > >> “$(pwd)/vendor/golang.org/x/sync/errgroup.(*Group).Go.func1” Not really > >> informative. I’d like to include/exclude specific stack frame from > appearing > >> on the regex level perhaps? e.g. > >> if I have stack A ->B->C and I’m filtering C, I’m expecting to see only > B > >> on the summary, and A->B in the details > > > > > > If you can use the annotation api, you can mark the interesting goroutine > > execution with Region and with the new trace (included in the tip) you > can > > select only the goroutines with the specified Region. > > > >> > >> In chrome tracing format specification, it says there are event types. I > >> cannot find how to do filtering on them in the catapult viewer > > > > > > I don't think the catapult viewer supports any kind of filtering based on > > the event type, or I am afraid I misunderstood what you want. > > > > > > -- > > __ > > > > -- > > You received this message because you are subscribed to the Google Groups > > "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send an > > email to golang-nuts+unsubscr...@googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] go tool trace: --> filtering/modifying
cool. if the granularity and the info open census provides is sufficient for your use case that’s the right way. go tool trace is for analyzing interaction between go runtime and the application. On Fri, May 25, 2018 at 1:22 PM Neven Miculinić wrote: > Hey, > > in the end I've used opencensus which has the same features as go's spans, > but it's designed for distributed tracing. I already have multiple backend > support, which supports more advanced filtering options than > chrome://tracings's catapult viewer. > > Thanks, > Neven Miculinić > > > On Tue, 8 May 2018 at 08:42, Tarmigan wrote: > >> In addition to the documentation that Hana pointed to, she also just >> gave a great talk that included a walk through of the new features and >> how they may be used to view high latency events: >> https://www.youtube.com/watch?v=FJQjUueBJ2A >> >> It's worth watching if you are interested in tracing and latency, and >> I'm looking forward to trying the new APIs soon. >> >> >> On Mon, May 7, 2018 at 1:31 PM, Hyang-Ah Hana Kim >> wrote: >> > Have you tried the new annotation api in the tip? >> > tip.golang.org/pkg/runtime/trace? >> > Please see if annotating in the source code with Region or Task would >> work >> > for your case. >> > >> > >> > On Wed, May 2, 2018 at 8:59 AM, wrote: >> >> >> >> High level goal: >> >> >> >> I have an application with significant number of goroutine experiencing >> >> latency issues. I want to detect and dissect where those issues arise >> and >> >> determine how can I fix them. For that I’ve use go tool trace >> >> >> >> Middle-level features: >> >> >> >> I want to filter event in the catapult viewer (( I cannot find >> >> documentation how to do it, and JS ecosystem I’m not really proficient >> in )) >> > >> > >> > What kind of filtering do you want to perform? >> >> >> >> Since I’m using errgroups, event names are all >> >> “$(pwd)/vendor/golang.org/x/sync/errgroup.(*Group).Go.func1” Not >> really >> >> informative. I’d like to include/exclude specific stack frame from >> appearing >> >> on the regex level perhaps? e.g. >> >> if I have stack A ->B->C and I’m filtering C, I’m expecting to see >> only B >> >> on the summary, and A->B in the details >> > >> > >> > If you can use the annotation api, you can mark the interesting >> goroutine >> > execution with Region and with the new trace (included in the tip) you >> can >> > select only the goroutines with the specified Region. >> > >> >> >> >> In chrome tracing format specification, it says there are event types. >> I >> >> cannot find how to do filtering on them in the catapult viewer >> > >> > >> > I don't think the catapult viewer supports any kind of filtering based >> on >> > the event type, or I am afraid I misunderstood what you want. >> > >> > >> > -- >> > __ >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "golang-nuts" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an >> > email to golang-nuts+unsubscr...@googlegroups.com. >> > For more options, visit https://groups.google.com/d/optout. >> > -- __ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Freeing memory of a cgo library
Memory allocated by one C/C++ runtime must and can only be freed through the same runtime. This is not a Go/cgo problem, this is normal C/C++ behavior. So by mixing gcc and msvc there are at least 2 C/C++ runtimes. Even mixing different compiler versions might cause issues. On Saturday, 26 May 2018 00:47:58 UTC+8, Liron Levy wrote: > > Hey Jake, > > First if all thanks for the willing to help. > > Cgo is the built-in tool in go of building c libraries (see: > https://golang.org/cmd/cgo/) > > What I basically do is that I have a go code, which i build into c library > (dll), i.e, i insert the go code onto the cgo mechine then get .h and .dll > on the otherside. > > The memory is allocated inside the .dll using C.malloc (which is basically > c malloc), and i try to free it inside the cpp file which is linked to this > dll. > > If i build a function inside the go code to free a recived pointer, which > will end up in the dll, then the problem is avoided. > > That being said, due to the fact that I have quite a few callbacks and a > large data transfer between the dll and my app i would like to keep it > simple and not have to use a third function to free the mallocs, as it is > also a problem if it happens the other way around, i.e., if i allocate > memory in the app and try to free it inside the library. > > Sorry if im unclear i tried to explsin it the best as i can. > > Ps yes i do use windiws, a side remark is that if i use gcc this does not > happen. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Freeing memory of a cgo library
Well it is kinda reoated as im in this mass because of go :) Anyway, is there anyway to use cgo with msvc? I actually run the cgo command from msvc cmd assuming the c part will be compiled with msvc. In addition as far as i know you can actually do that with visual studio if you put the /md (multi threading) flag on. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] time.Now takes ~3758 ns/op, is that normal?
Thank you! I think at this point it is very clear that this problem is due to some weird alternative normal of my computer. D: I will found another time to test it on another OS. 在 2018年05月25日 15:40, mfriedenha...@gmail.com 写道: Hello, I downloaded your gist and these are my results: ~/.Trash$ $ curl -s -O https://gist.githubusercontent.com/reinit/82608ab20e5aac3bd3c1eb5a8f78d23c/raw/bbc6fdb1ad0f137a66a986fe2af931ea477b5625/time_now_test.go ; go version ; go test -bench . go version go1.10.2 darwin/amd64 goos: darwin goarch: amd64 BenchmarkTimeNow-4 1 15.6 ns/op PASS ok _/Users/USERNAME/.Trash 1.587s Modellname: MacBook Pro Modell-Identifizierung: MacBookPro9,2 Prozessortyp:Intel Core i5 Prozessorgeschwindigkeit:2,5 GHz Anzahl der Prozessoren: 1 Gesamtanzahl der Kerne: 2 L2-Cache (pro Kern): 256 KB L3-Cache:3 MB Speicher:16 GB Systemversion: macOS 10.13.4 (17E202) Kernel-Version: Darwin 17.5.0 Regards Mirko -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] guru on Windows limits referrers to the same package
Hi, I just had to move my GO environment from Linux to Windows 10. I set up everything as simple as possible (GOROOT = C:\go, GOPATH = %USERPROFILE%\go) to test the installation. For an IDE I use vscode. When trying to see all referrers of a struct type vscode only shows references within the same package. I ran the guru command in a cmd shell and that also only shows references within a package. Setting up a fresh GO and vscode in a Ubuntu VM gives me back a whole lot more references (as does Intellij Idea). I also set up GO inside WSL and sure enough, there it works too! Is that a known problem of guru on Windows? Is there something I can do to workaround that? Thank you, Torsten! My GO environment is: λ go env set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\tuhlmann\AppData\Local\go-build set GOEXE=.exe set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\Users\tuhlmann\go set GORACE= set GOROOT=C:\go set GOTMPDIR= set GOTOOLDIR=C:\go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set CXX=g++ set CGO_ENABLED=1 set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\tuhlmann\AppData\Local\Temp\go-build087916374=/tmp/go-build -gno-record-gcc-switches -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] how to reuse getters and setters of two different versions of struct ? [interface{}/generics]
Hi, I have a use case where there are two different versions of struct. The problem is when the model is retrieved from database, it can be of either version. Both structs have same getters implemented. This is what the code looks like. type structA { Key1 string Key2string } func(s *structA) GetKey1() string { return s.key1 } type structB { Key3 string Key4string } func(s *structB) GetKey1() string { return s.key3 } version, obj, err := getObjFromDB(args) if err != nil { return err } var objA *structA var objB *structB if version == "A" { objA := obj.(structA) } else if version == "B" { objB := obj.(structB) } I want this logic to be abstracted to one object so that subsequent code should like obj.GetKey() -> doesn't matter whether obj is of type structA or structB Any help is greatly appreciated. Thanks for your time to look into this. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Freeing memory of a cgo library
Nope, not ATM. Go only works with gcc, even the dlls are made with gcc. There is a issue on that and it seems like there is some progress but it isn't clear when it will be usable. https://github.com/golang/go/issues/20982 Also note that even if Go uses msvc, you would still have issues freeing memory allocated in the dll through the exe unless maybe both of them are not static linking the runtime and are using the exact same runtime. You can see this for some info on the topic https://blogs.msdn.microsoft.com/oldnewthing/20060915-04/?p=29723 On Saturday, 26 May 2018 02:15:32 UTC+8, Liron Levy wrote: > > Well it is kinda reoated as im in this mass because of go :) > > Anyway, is there anyway to use cgo with msvc? I actually run the cgo > command from msvc cmd assuming the c part will be compiled with msvc. > > In addition as far as i know you can actually do that with visual studio > if you put the /md (multi threading) flag on. > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: Freeing memory of a cgo library
Gotcha :) Thanks for the info, guess i will have to find a way around it then. At least i now know there is no real way to do what i wanted so that close this door :) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: how to reuse getters and setters of two different versions of struct ? [interface{}/generics]
This is what interfaces are for. You have: type GetKeyer interface { GetKey1() string GetKey2() string } Then to use it: https://play.golang.org/p/rvLsWCIBuxe You still have to implement GetKey1 and GetKey2 on each struct, but you can access them through a common interface without knowing the actual type. On Saturday, 26 May 2018 02:23:39 UTC+8, anil kuncham wrote: > > Hi, > > I have a use case where there are two different versions of struct. The > problem is when the model is retrieved from database, it can be of either > version. Both structs have same getters implemented. > This is what the code looks like. > > type structA { >Key1 string >Key2string > } > > func(s *structA) GetKey1() string { > return s.key1 > } > > > type structB { >Key3 string >Key4string > } > > func(s *structB) GetKey1() string { > return s.key3 > } > > version, obj, err := getObjFromDB(args) > if err != nil { > return err > } > > var objA *structA > var objB *structB > > if version == "A" { > objA := obj.(structA) > } else if version == "B" { > objB := obj.(structB) > } > > > I want this logic to be abstracted to one object so that subsequent code > should like > > obj.GetKey() -> doesn't matter whether obj is of type structA or structB > > Any help is greatly appreciated. Thanks for your time to look into this. > > > > > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Future of Frozen Packages
So I'm going thru some of the Github issues, I'm wondering what will become of these packages that are frozen in the stdlib: - log/syslog (Implements logging facilities for *nix operating systems) - net/smtp (Implements RFC 5321) - net/rpc (Implements remote procedure calls for Go-Only programs.) - testing/quick (utility functions to help with black box testing) I don't know the future of these packages, all I know there not accepting any new features (Thou I'm unsure if there even set for deprecation in Go2). Would there be a reason to submit a Github issue for keeping / removing any of these packages for Go2? If so what do y'all think of these packages? My take is to keep net/smtp and net/rpc, I'm too sure about the 2 others I didn't mention. Thoughts? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Re: how to reuse getters and setters of two different versions of struct ? [interface{}/generics]
Thank you Alex for your quick reply. I figured it out. Using Interfaces is the right way to solve this. On Friday, 25 May 2018 12:08:01 UTC-7, alex@gmail.com wrote: > > This is what interfaces are for. > > You have: > type GetKeyer interface { > GetKey1() string > GetKey2() string > } > > Then to use it: https://play.golang.org/p/rvLsWCIBuxe > You still have to implement GetKey1 and GetKey2 on each struct, but you > can access them through a common interface without knowing the actual type. > > On Saturday, 26 May 2018 02:23:39 UTC+8, anil kuncham wrote: >> >> Hi, >> >> I have a use case where there are two different versions of struct. The >> problem is when the model is retrieved from database, it can be of either >> version. Both structs have same getters implemented. >> This is what the code looks like. >> >> type structA { >>Key1 string >>Key2string >> } >> >> func(s *structA) GetKey1() string { >> return s.key1 >> } >> >> >> type structB { >>Key3 string >>Key4string >> } >> >> func(s *structB) GetKey1() string { >> return s.key3 >> } >> >> version, obj, err := getObjFromDB(args) >> if err != nil { >> return err >> } >> >> var objA *structA >> var objB *structB >> >> if version == "A" { >> objA := obj.(structA) >> } else if version == "B" { >> objB := obj.(structB) >> } >> >> >> I want this logic to be abstracted to one object so that subsequent code >> should like >> >> obj.GetKey() -> doesn't matter whether obj is of type structA or structB >> >> Any help is greatly appreciated. Thanks for your time to look into this. >> >> >> >> >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Type dependency graphs?
https://github.com/TrueFurby/go-callvis This is a really neat tool On Wednesday, May 23, 2018, Patrik Iselind wrote: > Hi guys, > > I'm after a way to visualize all types in my project spanning multiple > packages. This includes both which types are composed of which other types > and which functions are attached to the different types. Something similar > to UML class diagrams. > > Is there such a tool already or do i have to write it myself? All i can > find are packages that visualize dependencies between packages, i'm affter > what's in the packages. > > Regards, > Patrik > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Rohit Jain -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[go-nuts] Does Golang need the innovation of C++ move semantics too
1. Why does C++ introduce move semantics anyway? What problems is it going to solve? 2. How come Golang, C (Without ++) don’t have that move semantics yet? Will they need the move soon? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [go-nuts] Does Golang need the innovation of C++ move semantics too
On Fri, May 25, 2018 at 8:15 PM, Li Jianhua wrote: > > Why does C++ introduce move semantics anyway? What problems is it going to > solve? > How come Golang, C (Without ++) don’t have that move semantics yet? Will > they need the move soon? Move semantics in C++ permit classes that are expensive to copy to provide a mechanism by which those classes can be moved rather than copied. For example, in many implementations the C++ std::string class can be expensive to copy, because it requires allocating new memory for the copy and copying the string contents. When the compiler can determine that the string object is being moved rather than being copied, it can use move semantics to simply transfer the pointer rather than copying the contents. This does not apply to Go at all, because Go has no copy constructors. In Go copying or moving a value is always straightforward. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.