[go-nuts] Re: Syscall trouble with parameter handling

2017-02-21 Thread snmed
okay it says "E_INVALIDARGOne or more arguments are not valid
0x80070057", but what i am doing wrong with the parameters?




Am Dienstag, 21. Februar 2017 12:01:47 UTC+1 schrieb snmed:
>
> Ohh strange i missed that, i thought it's S_OK  because the error stated 
> "The operation completed successfully". So i need to find out why it is 
> failling, do you have any idea about the reason?
>
> Cheers
> snmed 
>
> Am Dienstag, 21. Februar 2017 11:16:08 UTC+1 schrieb brainman:
>>
>> According to the doco 
>> https://msdn.microsoft.com/en-us/library/windows/desktop/dn889862(v=vs.85).aspx
>> ```
>> Return value
>> If this function succeeds, it returns S_OK. Otherwise, it returns an 
>> HRESULT error code.
>> ```
>>
>> Your call returns 2147942487, and it is not S_OK. It must be the error 
>> code. You need to find out what that error means. 
>>
>> Alex
>>
>> PS: You should ignore r2 and err returned from ainit.Call. r2 is never 
>> set on windows, and err will contain value of 
>> GetLastError at the time when ainit.Call completes. But (accordng to the 
>> doco) AmsiInitialize does not set GetLastError value.
>>
>

-- 
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] Syscall trouble with parameter handling

2017-02-21 Thread snmed
Hi all

I try to use the syscall package to call a native Windows API and 
struggling with the call parameters. I calling the api

HRESULT WINAPI AmsiInitialize(
  _In_  LPCWSTR  appName,
  _In_  DWORDcoInit,
  _Out_ HAMSICONTEXT *amsiContext
);


my test app looks like this
package main

import (
"fmt"

"syscall"
"unsafe"

"golang.org/x/sys/windows"
)

func main() {
h := windows.MustLoadDLL("Amsi.dll")
defer h.Release()

ainit := h.MustFindProc("AmsiInitialize")
auinit := h.MustFindProc("AmsiUninitialize")
ascanstring := h.MustFindProc("AmsiScanString")

var context uintptr
r1, r2, err := ainit.Call(uintptr(unsafe.Pointer(syscall.
StringToUTF16Ptr("Scanner Tool"))), 0, uintptr(unsafe.Pointer()))
fmt.Println(context)
fmt.Println(r1, r2, err)
// output:
// 0
// 2147942487 0 The operation completed successfully.

unfortunately the call succeeds but the context is still zero. Probably i 
call the function with the wrong parameters but i can't work it out.
Has anybody a idea what could be wrong?

Thank you in advance
snmed

-- 
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: Syscall trouble with parameter handling

2017-02-21 Thread snmed
Ohh strange i missed that, i thought it's S_OK  because the error stated 
"The operation completed successfully". So i need to find out why it is 
failling, do you have any idea about the reason?

Cheers
snmed 

Am Dienstag, 21. Februar 2017 11:16:08 UTC+1 schrieb brainman:
>
> According to the doco 
> https://msdn.microsoft.com/en-us/library/windows/desktop/dn889862(v=vs.85).aspx
> ```
> Return value
> If this function succeeds, it returns S_OK. Otherwise, it returns an 
> HRESULT error code.
> ```
>
> Your call returns 2147942487, and it is not S_OK. It must be the error 
> code. You need to find out what that error means. 
>
> Alex
>
> PS: You should ignore r2 and err returned from ainit.Call. r2 is never set 
> on windows, and err will contain value of 
> GetLastError at the time when ainit.Call completes. But (accordng to the 
> doco) AmsiInitialize does not set GetLastError value.
>

-- 
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: Syscall trouble with parameter handling

2017-02-21 Thread snmed
Has anyone a hint, what i'm doing wrong with the Call arguments? I think 
the last parameter is the problematic one, but i can't figure out how to 
pass that argument.

Any help would be most appreciated!

Cheers snmed

Am Dienstag, 21. Februar 2017 10:36:29 UTC+1 schrieb snmed:
>
> Hi all
>
> I try to use the syscall package to call a native Windows API and 
> struggling with the call parameters. I calling the api
>
> HRESULT WINAPI AmsiInitialize(
>   _In_  LPCWSTR  appName,
>   _In_  DWORDcoInit,
>   _Out_ HAMSICONTEXT *amsiContext
> );
>
>
> my test app looks like this
> package main
>
> import (
> "fmt"
>
> "syscall"
> "unsafe"
>
> "golang.org/x/sys/windows"
> )
>
> func main() {
> h := windows.MustLoadDLL("Amsi.dll")
> defer h.Release()
>
> ainit := h.MustFindProc("AmsiInitialize")
> auinit := h.MustFindProc("AmsiUninitialize")
> ascanstring := h.MustFindProc("AmsiScanString")
>
> var context uintptr
> r1, r2, err := ainit.Call(uintptr(unsafe.Pointer(syscall.
> StringToUTF16Ptr("Scanner Tool"))), 0, uintptr(unsafe.Pointer()))
> fmt.Println(context)
> fmt.Println(r1, r2, err)
> // output:
> // 0
> // 2147942487 0 The operation completed successfully.
>
> unfortunately the call succeeds but the context is still zero. Probably i 
> call the function with the wrong parameters but i can't work it out.
> Has anybody a idea what could be wrong?
>
> Thank you in advance
> snmed
>
>

-- 
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: Syscall trouble with parameter handling

2017-02-22 Thread snmed
Okay thanks anyway

Am Mittwoch, 22. Februar 2017 11:51:45 UTC+1 schrieb brainman:
>
> > Has anyone a hint, what i'm doing wrong with the Call arguments?
>
> I do not know. Sorry.
>
> > I think the last parameter is the problematic one, ...
>
> It looks fine to me.
>
> Alex
>

-- 
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] Re: Syscall trouble with parameter handling

2017-02-22 Thread snmed
Hi Konstantin

Thanks a lot for your input. You were right about the second parameter and 
the call to ColInitalize, so now i'm a bit further but still get an error.
I will have a closer look on that error and hope i find a solution for it.

Cheers
snmed

Am Mittwoch, 22. Februar 2017 11:58:35 UTC+1 schrieb Konstantin Khomoutov:
>
> On Tue, 21 Feb 2017 22:55:18 -0800 (PST) 
> snmed <sandro@gmail.com > wrote: 
>
> > Has anyone a hint, what i'm doing wrong with the Call arguments? I 
> > think the last parameter is the problematic one, but i can't figure 
> > out how to pass that argument. 
>
> A couple of ideas: 
>
>   * [1] Features a comment by someone stating: 
>
> | The second parameter is not present in the latest API. 
> | 
> | The second parameter 
> | _In_  DWORDcoInit, 
> | is not present in the latest AMSI.dll. Use the below code if you are 
> | importing to C#. [DllImport("Amsi.dll", EntryPoint = "AmsiInitialize", 
> | CallingConvention = CallingConvention.StdCall)] public static extern 
> | int AmsiInitialize([MarshalAs(UnmanagedType.LPWStr)]string appName, 
> | out IntPtr amsiContext); 
> | 
> | Eler 
> | 12/6/2016 
>
> Which might mean you just need to drop the second 0 (coInit) and 
> make your pointer to context the second one. 
>
>   * An example presented at [2] clearly shows the code calls 
> CoInitialize() before attempting to initialize the AMSI library.  This 
> hints at that this library uses or is based on COM technology.  AFAIK, 
> to use anything COM-related in a thread, you first need to prepare that 
> thread for this -- by calling CoInitialize() or CoInitializeEx().  The 
> fact the second argument to AmsiInitialize() is called "coInit" hints 
> at that this might indeed be the cause. 
>
> Please note that since goroutines by default are multiplexed on any 
> number of OS threads, you will most probably need to call 
> runtime.LockOSThread() before doing anything with AMSI and make sure 
> all further calls to that lib are managed by that single goroutine -- 
> say, by making it serve calls on a channel. 
>
>   * I'm not sure how MustFindProc("AmsiInitialize") is defined to behave 
> with regard to "wide" vs "char" version of the API, so maybe -- for some 
> weird reason -- it manages to locate AmsiInitializeA(), and that one 
> gets confused with the wide character data you pass to it as its first 
> parameter?  Try explicitly requesting AmsiInitializeW() instead and see 
> whether that fixes the problem. 
>
> I'd say it's always a good idea to always refer to the API facet you 
> need explicitly (and these days you usually want FooW() in most cases). 
>
> 1. https://msdn.microsoft.com/en-us/library/windows/desktop/dn889862 
> (v=vs.85).aspx 
> <https://msdn.microsoft.com/en-us/library/windows/desktop/dn889862(v=vs.85).aspx>
>  
> 2. 
> https://social.msdn.microsoft.com/Forums/vstudio/zh-CN/28e6c37f-ac29-43e6-ba65-a7cbd23b6831/how-to-use-amsiinitialize-function-how-to-use-the-amsiantimalware-scan-interface?forum=visualcpluszhchs
>  
>

-- 
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] Named or unnamed struct initialisation? What is best practice?

2017-07-04 Thread snmed
Hi gophers

I've a litte question about best practice for struct initialisation.  For 
example one can initialise structs like:
type A struct {
   name  string
   firstName string
}

a1 := A{"Mueller", "Max"}
a2 := A{name: "Mueller", firstName: "Max"}

The first one is concise and intuitive, but the second is more robust in 
case of refactoring.
If anyone adds a string field at the beginning of the struct, it compiles 
fine but changes the meaning of all initialised structs in the project, if 
nobody 
pays attention to that.

Is there any best practice or advises how structs should be initialised 
and/or refactored?

Cheers

-- 
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: Named or unnamed struct initialisation? What is best practice?

2017-07-05 Thread snmed
Okay thanks, as I supposed. Personally i used always named initialisation 
despite of the overhead, but sometimes I feel the urge to use the short 
unamed initialisation. ;-)

Am Mittwoch, 5. Juli 2017 07:41:04 UTC+2 schrieb Tamás Gulácsi:
>
> Named.

-- 
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: Named or unnamed struct initialisation? What is best practice?

2017-07-05 Thread snmed
Hi rob

Thanks for your response. I didn't know that trick, but it seems to me a 
little bit ugly to guard fields that way. I will stick to named 
initialisations and write it as a policy into the style guide.

Cheers

Am Donnerstag, 6. Juli 2017 02:26:27 UTC+2 schrieb rob rodgers:
>
> for some of our sensitive structures that are tricky and have multiple 
> fields of the same type, there is a trick you can use:
>
> type bar struct {
>A int
>_ bool
> }
>
> see https://play.golang.org/p/rFKGoKq-S9
>
>
>

-- 
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] Goroutines chan to get data at specific time

2017-08-06 Thread snmed
Hi 

What are you trying to solve? Your channel has a capacity of 1, the first write 
to c1 is successful but the second write to c1 is blocked until it has been 
read in the select statement. And therefore you print the first value written 
to c1.

I recommend you to read this https://golang.org/doc/effective_go.html#channels 
documentation about channels.

Cheers snmed

-- 
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] Go channels overused and hyped?

2017-08-08 Thread snmed
Hi Gophers

I stumbled over a nice and very interesting Blog entry "Go channels are bad 
and you should feel bad 
<http://www.jtolds.com/writing/2016/03/go-channels-are-bad-and-you-should-feel-bad/>"
 
, I would like to hear some opinions about that article
from seasoned go developers. Because I just used go for a couple of months 
for my private web projects and rarely get in touch with channels.

By the way, that article is not a rant and the author likes go very much as 
far as I can conclude from the article.

Cheers snmed

-- 
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: Go channels overused and hyped?

2017-08-08 Thread snmed
Hi Egon

Thank you for your reply, I myself used channel as a semaphore, i'm not 
sure if that is a appropriate use case for channels.

Anyhow your opionion is very welcome
 

Am Dienstag, 8. August 2017 09:26:35 UTC+2 schrieb Egon:
>
> There are trade-offs.
>
> Channels are easy to use for simple things, but complicated for complected 
> things.
>
> Locking data-structures can easily introduce data-races (see The Little 
> Book of Semaphores http://greenteapress.com/wp/semaphores/).
>
> The Game/Player example looks weird to me; there's one piece missing -- 
> without it, the full complexity is not seen.
>
> With regards to callbacks (context.Done) specifically, in one case you 
> control the goroutine it gets executed in, in the other not.
>
> Not closing the waiting channel inside context leaking goroutine is 
> moot... when you forget to invoke the callbacks, you will leak as well when 
> you have resource releasing in the callback.
>
> Channels are quite good for producer-consumer things, but tend to get very 
> complicated for dispatches.
>
> *tl;dr; channels and locking have trade-offs, instead of hopping on the 
> bandwagon, understand the trade-offs and pick the one that is most suitable 
> in a certain situation.*
>
> + Egon
>
> On Tuesday, 8 August 2017 09:01:12 UTC+3, snmed wrote:
>>
>> Hi Gophers
>>
>> I stumbled over a nice and very interesting Blog entry "Go channels are 
>> bad and you should feel bad 
>> <http://www.jtolds.com/writing/2016/03/go-channels-are-bad-and-you-should-feel-bad/>"
>>  
>> , I would like to hear some opinions about that article
>> from seasoned go developers. Because I just used go for a couple of 
>> months for my private web projects and rarely get in touch with channels.
>>
>> By the way, that article is not a rant and the author likes go very much 
>> as far as I can conclude from the article.
>>
>> Cheers snmed
>>
>

-- 
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: Go channels overused and hyped?

2017-08-08 Thread snmed
Hi Dave

Thank you for your comment, I will read your talk on my way back home later 
and I'm sure i get some better insight in go concurrency.
But his argument about better performance of mutex over channels is still 
valid, maybe you have covered that in your talk, i will see later.

Cheers snmed


Am Dienstag, 8. August 2017 09:51:08 UTC+2 schrieb Dave Cheney:
>
> Everyone overused channels and goroutines at first. Why wouldn't you? 
> That's why you probably decided to try Go in the first place.
>
> I have a talk in Singapore a few months ago trying to explore this idea. 
> It sort of went in a different direction, but the conclusion might be 
> interesting for you.
>
> https://dave.cheney.net/paste/concurrency-made-easy.pdf
>
>

-- 
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] gopherjs files, writing, loading

2017-08-04 Thread snmed
Hi "me"

I don't know gopherjs well, but as far as I know, they only provide an api to 
the html 5 feature

localStorage and sessionStorage, see 
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

so you can't write directly to the filesystem with js via a browser.

Cheers snmed

-- 
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: Goroutines chan to get data at specific time

2017-08-06 Thread snmed
I still no get the idea behind your requirement, in your example you 
calling the web service 6 times in sequential manner and then write it to 
the channel.
But again you can only write once to a channel with a capacity of one, as 
long as you not read from the same channel and you still read it in the 
select statement.
That means all other calls to 'GetPartWebServiceData()' in the goroutine 
are blocked until that read in the select statement happens. In your case 
it is always the first
value written to the channel.

I try to give you a solution with although i'm not completely understand 
your requirements:

Here a working sequential solution: https://play.golang.org/p/2qohwIjP96

I hope that helps

Cheers snmed

Am Sonntag, 6. August 2017 13:05:11 UTC+2 schrieb Abhijit Desai:
>
> Requirement is to collect the data with in cuttoff time say 3 sec by 
> invoking web service multiple times and return only latest invoked data
>
> c1 <- "result 1" // In real scenario this taking almost 1 seconds as in 
> real scenario it's taking Part chunk of data from Web Service
>
> Something like... Expecting data from c1 <- GetPartWebServiceData("request 
> 3") //at least I should get this data!?
>
>
> package main
>
> import "time"
> import "fmt"
>
> func main() {
>
> c1 := make(chan string, 1)
> 
> go func() {
>   
> c1 <- GetPartWebServiceData("request 1") //say try 6 times
> c1 <- GetPartWebServiceData("request 2")
> c1 <- GetPartWebServiceData("request 3") //at least I should get 
> this data!?
> c1 <- GetPartWebServiceData("request 4")
> c1 <- GetPartWebServiceData("request 5")
> c1 <- GetPartWebServiceData("request 6")
> }()
>
> select {
> case res := <-c1: //here program get out without waiting 3 
> seconds because it got the data
> fmt.Println(res)
> case <-time.After(time.Second * 4):
> fmt.Println("timeout")
> }
> }
>
> func GetPartWebServiceData(request string) string{
> time.Sleep(time.Second * 1) // Time Consuming work returning part value
> partResponse := "Response for " + request  //some response
> return partResponse
> }
>
>
>
> On Sunday, August 6, 2017 at 4:03:08 PM UTC+5:30, snmed wrote:
>>
>> Hi 
>>
>> What are you trying to solve? Your channel has a capacity of 1, the first 
>> write to c1 is successful but the second write to c1 is blocked until it 
>> has been read in the select statement. And therefore you print the first 
>> value written to c1.
>>
>> I recommend you to read this 
>> https://golang.org/doc/effective_go.html#channels documentation about 
>> channels.
>>
>> Cheers snmed
>>
>>

-- 
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 channels overused and hyped?

2017-08-18 Thread snmed
Hi Michael

Thank you very much for your very informative and elaborating post. I never 
had seen that blog this way, but your post has opened my eyes and now is 
clear that one should not compare apples with pears.
So the tradeoff is, use concurrency in a safe manner or squezze the last 
drop performance out of the application, but be aware of shooting in your 
own leg. So the conclusion is, use channels to get the job done and
if in real use any performance problem pops up, analyze it and verify if 
the bottleneck is really caused by channels and if it's not a fault in the 
architecture , right?

Cheers snmed


Am Samstag, 12. August 2017 23:37:45 UTC+2 schrieb Michael Jones:
>
> snmed, 
>
> My disappointment with that blog post is that it does not address the 
> larger issue, which some people here have clarified, but to be clear on the 
> larger issue and the various points raised about channels:
>
> SMALL BENCHMARKS ARE HARD
>
> Benchmarking is harder than it seems, because computers since the IBM 
> 360/85 (1969), the DEC PDP-11/70 (1975), and a others before have memory 
> caches. They can also have multiple CPUs, multiple levels of memory cache, 
> and since 1964's CDC 6000, multiple threads active in a single CPU (the 
> basis of the first NVIDIA GeForce GPU and rediscovered by intel as Jackson 
> Technology, aka SMT, a few years later).
>
> In a world where computers read, write, and compute multiple things at 
> once, it is quite difficult to measure the cost of any single thing. Why? 
> Because if that one thing can be done in some idle part of the computer 
> while other things are happening, then the effective cost is zero. 
>
> Even if you manage to measure that one thing somehow with sufficient 
> scaffolding and after disabling your modern CPU's power saving speed 
> degrader and myriad other processes and performance modulators such as 
> inside the CPU uOp dispatch priority and the like, the problem is, how to 
> understand it and extrapolate from it.
>
> To be clear, if it takes a perfectly measured average of 140 ns +/- 11ns 
> to do something, and you do 100 of them, it will likely not add 100x that 
> time or 100x that variance to your application's actual performance rates. 
> Maybe all 100 of those fit in "empty spots" so the cost is zero. Maybe they 
> conflict with instruction scheduling, bus activity, or cache/VM activity in 
> such a way that they add 10x that time. 
>
> This is why microbenchmarks are so hard to understand. They are hard to 
> write properly, they are hard to measure in a meaningful way, and they are 
> hard to extrapolate with confidence. (You should do them, but, you should 
> always keep in mind that the application-level, real-world impact may be 0x 
> or 100x that much cost.)
>
> CONCURRENT PROGRAMMING IS HARD
>
> Doing things concurrently generally implies one or more spreading steps 
> where the code widens one thing to multiple things, and one or more 
> gathering steps where the multiple things narrow to fewer things, 
> ultimately to one thing, like knowing when to exit the program. For decades 
> there have been frequent errors in widening, narrowing, and data and device 
> conflicts in the concurrent phase. Code that works for years may suddenly 
> break. Code that looks simple my never work. Natural intuition in such 
> cases often leads one astray.
>
> One solution is to be afraid of concurrency and avoid it. One is to 
> embrace it, but with special armor as if handling hot lava or a pit of 
> vipers. A middle route is to only allow it in such a way that it its tame 
> (Lava in insulated containers, snakes asleep in darkened boxes.) One such 
> mild route--Communicating Sequential Processes--was pioneered by C. A. R. 
> Hoare, the inventor of Quicksort. Per Brinch Hansen has an excellent book 
> about OS construction via the method, and Go is one of CSP's direct 
> decedents. Go's channels, along with select, receive, send, and close 
> operations, are its presence. 
>
> SMALL BENCHMARKS OF CONCURRENCY PRIMITIVES IS VERY HARD
>
> It is hard to measure directly in much the same way it is hard to directly 
> measure curved space-time. Indirect ways are hard too. As above, even when 
> you can measure them, it is hard to understand what that data says in the 
> context of your program or any program other than the test harness. 
>
> This is where that blog post comes in. To paraphrase, "I think some of 
> Go's mild, safe mechanisms lack a feature that I wish for, and not only 
> that, when I use them to emulate some parts of my low-level lava-juggling 
> armor, they are not as fast. Oh no! Yet, I still love Go." Well people see 
> that, seem to miss:
>
> a. Why in the heck would you use high-level mag

[go-nuts] Re: Released sting 1.0.0

2017-10-03 Thread snmed
Hi Egon

Thank you very much for your feedback. You confirmed my assumption about di 
libraries in go and your links fortified this impression. Probably I have 
to rethink some old C# habits and map them to a more go idiomatic style.



> It's difficult to evaluate the API because the examples aren't real-world.
>
 
Fair point, I'll check if I can use some real code from my other projects 
for the examples. 


> I would consider something like this instead of fluent interface:
>
> container := sting.NewContainer(
> UsefulStruct{"Very useful"},
> sting.NamedTransient("alsoUseful", {"More useful"}),
> )
>
>
Hmm... I like your idea, I take a note for the next version, but for the 
current version I'll keep the public API. I don't want a bigger API so your 
idea would replace the current builder.Register and builder.RegisteredNamed 
functions.

Cheers,
Sandro

-- 
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] Latest Tiobe Ranking

2017-10-09 Thread snmed
I've seen the latest Tiobe Index https://www.tiobe.com/tiobe-index/ 
How could that happen, dropped onto the 20th rank? Has someone a better source 
of go's adoption in the wild?

Cheers

-- 
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] Latest Tiobe Ranking

2017-10-09 Thread snmed
Hi Ian

Thank you for your elaboration. I won't choose a language because of such 
index, but I'm trying to convince my colleagues of the benefits of go and 
therefore no matter how funny such indexes are, it isn't useful as well. I'm 
always looking for success stories about using go from other companies.

Cheers

-- 
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] Tools for 80 column split for golang

2017-09-07 Thread snmed
Hi 

*Typically you can break your lines after comma ,, 
> after opening parenthesis e.g. (, [, {, and after a dot . which may be 
> referencing a field or method of some value. You can also break your line 
> after binary operators (those that require 2 operands), e.g.:*

Complete answer: 
https://stackoverflow.com/questions/34846848/how-to-break-a-long-line-of-code-in-golang#answer-34848928

And here a simple example with fmt.Println: 
https://play.golang.org/p/tP8zkOo79l 

Cheers snmed

Am Donnerstag, 7. September 2017 10:24:19 UTC+2 schrieb Sankar:
>
> Even with most modern laptops, I found having 80 column limit is very 
> useful, when we split panes and read code. May be it is just my personal 
> preference :)
>
> 2017-09-07 12:05 GMT+05:30 Jakob Borg <ja...@kastelo.net >:
>
>> On 7 Sep 2017, at 06:10, Sankar <sankar.c...@gmail.com > 
>> wrote:
>> >
>> > Are there any tools available for golang to split long functions so 
>> that they can fit in 80 columns (as long as possible) ?
>>
>> Don't fear longer lines, most of us are not on text mode terminals any 
>> more. :)
>>
>> When it becomes *too* long it's probably hard to read due to being a too 
>> large or too complex expression, not the line length per se. My preferred 
>> solution would be to split it up with a variable or two. I don't think 
>> there is a tool for that, it requires human consideration.
>>
>> //jb
>>
>>
>
>
> -- 
> Sankar P
> http://psankar.blogspot.com 
>

-- 
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] Re: error handling needs syntactical sugar

2017-09-07 Thread snmed
Hi Tim

If you want halt the app, you should call panic, that's already a go 
built-in. Think it would apply to your proposal as well, despite i do not 
agree with it.

Cheers snmed

Am Donnerstag, 7. September 2017 14:42:12 UTC+2 schrieb Tim Uckun:
>
> >I *like* the way go does error passing, *because* it's constrained to 
> handle errors explicitly.
>
> But it doesn't though. You can completely ignore the errors if you want. >
>
> >TBH, no. Not only do I not know what this is supposed to be doing 
> (err.pop? of what? Why are we assigning to error? What is happening here?), 
> at best the code seems equivalent to the current code, to me. There is a 
> function call, a conditional to check for error and then some error 
> handling. When skimming that code, it would look pretty much identical to 
> the current idiom.
>
>
> I guess I should have explained it more clearly.
>
> I was proposing that there should be a language construct called errors. 
> This would be an array. As exceptions are raised the program would push the 
> errors into this array. At any time you could examine the array to see if 
> there were errors and if so what they were. When I said "err.pop" I was 
> indicating that the program would remove the latest error from the stack to 
> examine it and act on it. 
>
> This would eliminate a lot of boilerplate but conceptually be the same 
> kind of error handling. Instead of returning a value, err pair you simply 
> return the value or you raise an exception.  The called can check if an 
> error was raised by calling some method to indicate whether or not the 
> errors array is empty. 
>
> For example
>
> x = someMethod()
> // if there was an error in there it would populate the array but we don't 
> have to explicitly receive the err in the return.
> ifErr { 
>// fetch the error
> err = errors.pop()
>something()
> }
>
> Something like that. 
>
> I also realize that sometimes you may want to halt the app on errors so 
> there should be a way to bypass this by some kind of declaration.
>
>

-- 
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: Example output not visible in godoc

2017-09-25 Thread snmed
Hi all

I found the problem, but i'm not sure if it's a bug or not. If i move the 
type and function declarations to a different file, it works as it should.
But as described here: https://blog.golang.org/examples 
<https://blog.golang.org/examples#TOC_5.> it should be possible to use own 
types in the examples.

By the way i'm using go 1.9 on macOS, maybe someone can test if this 
behavior is the same for 1.8.3.
Also i wondering if godoc.org is on version 1.9 or does it use an older 
version?

Cheers

Am Montag, 25. September 2017 10:54:57 UTC+2 schrieb snmed:
>
> Hi all
>
> I have some problem with my go examples, in some case the output is 
> correct rendered in a code block, but for other examples it is not rendered 
> in a separat code block.
>
> Here the link to the documentation of my package: 
> https://godoc.org/bitbucket.org/snmed/sting
>
> For example GetService the output is rendered correct.
> For example Inject it is not rendered correct.
>
> Has anyone an idea why it is no working correct?
>
> Thank you in advance
> Sandro
>

-- 
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] Released sting 1.0.0

2017-10-02 Thread snmed
Hi all

I released my first open source go project: 
https://bitbucket.org/snmed/sting 

It's a simple DI library and is used for my own projects. I'm not sure how 
idomatic go it is, but I primarily started it to learn the go reflection 
package and capabilities.
I'm sure there is still a lot to improve and the best way to find weak 
spots, is to use or/and have some additional eyes on it.  

Any suggestions, constructive criticism and feedback is warmly welcome.

Regards


-- 
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] Example output not visible in godoc

2017-09-25 Thread snmed
Hi all

I have some problem with my go examples, in some case the output is correct 
rendered in a code block, but for other examples it is not rendered in a 
separat code block.

Here the link to the documentation of my package: 
https://godoc.org/bitbucket.org/snmed/sting

For example GetService the output is rendered correct.
For example Inject it is not rendered correct.

Has anyone an idea why it is no working correct?

Thank you in advance
Sandro

-- 
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] Example output not visible in godoc

2017-09-25 Thread snmed
Thank you for your answer, but nope doesn't make any difference, at least 
not with local godoc instance.

Am Montag, 25. September 2017 11:03:55 UTC+2 schrieb Jan Mercl:
>
> On Mon, Sep 25, 2017 at 10:55 AM snmed <sandro@gmail.com > 
> wrote:
>
> > Has anyone an idea why it is no working correct?
>
> Blind shot: Try removing the final empty line: 
> https://bitbucket.org/snmed/sting/src/85748cacc8970f60582428bf05d52fcfb051ba5f/example_inject_test.go?at=master=file-view-default#example_inject_test.go-87
>
> -- 
>
> -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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: Should we stop using a global logger?

2017-08-25 Thread snmed
Hi Dave

I've read about this context.Value topic on several occasion and in your blog 
post you say context is only for cancelation. But how should one cope with real 
goroutine specific data, unfortunately i missed always a correct solution for 
this problem.

Any proposal is welcome

Cheers snmed

-- 
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] can list.List.Push* or Get return nil?

2017-08-28 Thread snmed
Hi 

As far as the docs are right:

For Back: Back returns the last element of list l or nil.

For PushBack:  PushBack inserts a new element e with value v at the back of 
list l and returns e.

So if you push nil, you get nil otherwise you get always your pushed element.

Cheers

-- 
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: sync.Map for caching

2017-09-01 Thread snmed
Hi 

Here are two examples how to achieve it: 
https://play.golang.org/p/wAtyGMSw6g or https://play.golang.org/p/EZWZUOpuwb

First example: In best cases it executes the creator function once and 
returns always the stored item, in bad cases it executes the creator 
function multiple times but returns always the first
stored item. 

Second example uses a lock to create and store the item.

If the creator function is expensive, then I would use the latter example 
otherwise the first.

Cheers snmed


Am Freitag, 1. September 2017 00:18:35 UTC+2 schrieb bep:
>
> sync.Map in Go 1.9 is a little low on examples/doc in the wild, so I 
> thought I should ask here.
>
> The new type is promoted as a replacement for  RWMutex in mostly read use 
> cases with stable keys. I assume that a typical in memory cache would fit 
> that description.
>
> With RWMutex, if the cost of creating the cache item is high, I would 
> maybe do something ala:
>
> mu.RLock()
> // Check cache
> mu.RUnclock()
>
> // Return if found
>
> // If Not found:
> mu.Lock()
> defer mu.Unlock()
> // Double check cache, return if found
> // Create item and put in cache
>
>
>
>
> I don't see how the above can be written with a sync.Map without adding a 
> mutex.
>
> bep
>

-- 
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: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread snmed
Hi Bryan

But the returned uintptr from syscall is as far as i know a pointer to a 
struct which has been created by the C API, so go runtime won't touch it or 
do I miss something?

Am Freitag, 15. Dezember 2017 00:48:51 UTC+1 schrieb Bryan Mills:
>
> In this case, the vet tool is correct if you're making the syscall with 
> Go-allocated memory.
> The Go runtime is allowed to move values around: the address of a Go 
> variable is only pinned for the duration of the syscall itself.
>
> If you've got C-allocated memory (or statically-allocated memory), 
> https://golang.org/issue/13656#issuecomment-303216308 has a solution that 
> avoids copying and is more robust to large sizes.
>
>
> On Thursday, December 14, 2017 at 5:27:57 AM UTC-5, snmed wrote:
>>
>> Okay I found a way, this seems to work:
>>
>> ca := (*[100]byte) (unsafe.Pointer(certctx.pbCertEncoded))[:certctx.
>> cbCertEncoded]
>>
>> or
>>
>> mm := make([]byte, certctx.cbCertEncoded)
>> for i := uint32(0) ; i < certctx.cbCertEncoded; i++ {
>> mm[i] = *((*byte)(unsafe.Pointer(certctx.pbCertEncoded + uintptr(
>> i) * unsafe.Sizeof(new(byte)
>> }
>>
>>
>>
>> Anyway, the vet tool is complaining:
>>
>> main.go:106: possible misuse of unsafe.Pointer
>> main.go:109: possible misuse of unsafe.Pointer
>>
>> This is the code fragment:
>>
>> 104certctx := new(CERT_CONTEXT)
>> 105
>> 106certctx = (*CERT_CONTEXT) (unsafe.Pointer(pccert_context))
>> 107
>> 108
>> 109ca := (*[100]byte) (unsafe.Pointer(certctx.pbCertEncoded))[:
>> certctx.cbCertEncoded]
>>
>> Is there another way to use syscall return values uintptr without vet 
>> warnings? And which solution should I prefer? I think the later one should 
>> be more safe, isn't it?
>>
>> Cheers
>>
>>
>> Am Donnerstag, 14. Dezember 2017 09:29:38 UTC+1 schrieb snmed:
>>>
>>> Hi Miki 
>>>
>>> I'm using syscall package and no C import, but maybe it is possible to 
>>> use this function as well?
>>>
>>> Am Donnerstag, 14. Dezember 2017 09:18:26 UTC+1 schrieb Miki Tebeka:
>>>>
>>>> Do you mean
>>>>
>>>> func C.GoBytes(unsafe.Pointer, C.int) []byte
>>>>
>>>>  ?
>>>>
>>>> On Thursday, December 14, 2017 at 9:05:32 AM UTC+2, snmed wrote:
>>>>>
>>>>> Hi all
>>>>>
>>>>> I'm trying to map a C structure to an equivalent go struct, but I 
>>>>> bumped into a problem with a pointer to byte that is actually an array of 
>>>>> bytes.
>>>>>
>>>>> Here is the C struct:
>>>>>
>>>>> typedef struct _CERT_CONTEXT {
>>>>>   DWORD  dwCertEncodingType;
>>>>>   BYTE   *pbCertEncoded;
>>>>>   DWORD  cbCertEncoded;
>>>>>   PCERT_INFO pCertInfo;
>>>>>   HCERTSTORE hCertStore;
>>>>> } CERT_CONTEXT, *PCERT_CONTEXT;
>>>>>
>>>>>
>>>>> and this is my go struct:
>>>>>
>>>>> type CERT_CONTEXT struct {
>>>>> dwCertEncodingType uint32
>>>>> pbCertEncoded  uintptr
>>>>> cbCertEncoded  uint32
>>>>> pCertInfo  uintptr
>>>>> hCertStore uintptr
>>>>> }
>>>>>
>>>>> for my case I need only the first 3 fields and I do not have any 
>>>>> problem to get 1 and 3, but I can't remember how to translate the second 
>>>>> field to a slice of bytes.
>>>>> This is how I map the struct from an uintptr and print it to the 
>>>>> console:
>>>>>
>>>>> certctx = (*CERT_CONTEXT) (unsafe.Pointer(pccert_context))
>>>>> fmt.Printf("%v\n", certctx)
>>>>> 
>>>>> >&{1 807520 674 833008 789360}
>>>>>
>>>>> Any advise is warmly welcome.
>>>>>
>>>>> Cheers,
>>>>> Sandro
>>>>>
>>>>

-- 
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] Re: Mapping C pointer to BYTE to golang []byte

2017-12-15 Thread snmed
Sorry if I wasn't clear about that, I calling CertFindCertificateInStore 

 which 
according to MSDN returns a pointer to a struct of type PCCERT_CONTEXT and 
must be freed with CertFreeCertificateContext 

.

The returned pointer is freed when passed as the *pPrevCertContext* 
> parameter on a subsequent call to the function. Otherwise, the pointer must 
> be explicitly freed by calling *CertFreeCertificateContext* 
> .
>  
> A *pPrevCertContext* that is not *NULL* is always freed by 
> *CertFindCertificateInStore* using a call to *CertFreeCertificateContext*, 
> even if there is an error in the function.


So yes it is allocated by the crypt API of Windows, but i'm still not sure 
if can ignore the vet warning or not. As far as I understand, go only 
manages the pointer to the struct but not the struct itself.

-- 
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] Mapping C pointer to BYTE to golang []byte

2017-12-13 Thread snmed
Hi all

I'm trying to map a C structure to an equivalent go struct, but I bumped 
into a problem with a pointer to byte that is actually an array of bytes.

Here is the C struct:

typedef struct _CERT_CONTEXT {
  DWORD  dwCertEncodingType;
  BYTE   *pbCertEncoded;
  DWORD  cbCertEncoded;
  PCERT_INFO pCertInfo;
  HCERTSTORE hCertStore;
} CERT_CONTEXT, *PCERT_CONTEXT;


and this is my go struct:

type CERT_CONTEXT struct {
dwCertEncodingType uint32
pbCertEncoded  uintptr
cbCertEncoded  uint32
pCertInfo  uintptr
hCertStore uintptr
}

for my case I need only the first 3 fields and I do not have any problem to 
get 1 and 3, but I can't remember how to translate the second field to a 
slice of bytes.
This is how I map the struct from an uintptr and print it to the console:

certctx = (*CERT_CONTEXT) (unsafe.Pointer(pccert_context))
fmt.Printf("%v\n", certctx)

>&{1 807520 674 833008 789360}

Any advise is warmly welcome.

Cheers,
Sandro

-- 
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: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread snmed
Hi Miki 

I'm using syscall package and no C import, but maybe it is possible to use 
this function as well?

Am Donnerstag, 14. Dezember 2017 09:18:26 UTC+1 schrieb Miki Tebeka:
>
> Do you mean
>
> func C.GoBytes(unsafe.Pointer, C.int) []byte
>
>  ?
>
> On Thursday, December 14, 2017 at 9:05:32 AM UTC+2, snmed wrote:
>>
>> Hi all
>>
>> I'm trying to map a C structure to an equivalent go struct, but I bumped 
>> into a problem with a pointer to byte that is actually an array of bytes.
>>
>> Here is the C struct:
>>
>> typedef struct _CERT_CONTEXT {
>>   DWORD  dwCertEncodingType;
>>   BYTE   *pbCertEncoded;
>>   DWORD  cbCertEncoded;
>>   PCERT_INFO pCertInfo;
>>   HCERTSTORE hCertStore;
>> } CERT_CONTEXT, *PCERT_CONTEXT;
>>
>>
>> and this is my go struct:
>>
>> type CERT_CONTEXT struct {
>> dwCertEncodingType uint32
>> pbCertEncoded  uintptr
>> cbCertEncoded  uint32
>> pCertInfo  uintptr
>> hCertStore uintptr
>> }
>>
>> for my case I need only the first 3 fields and I do not have any problem 
>> to get 1 and 3, but I can't remember how to translate the second field to a 
>> slice of bytes.
>> This is how I map the struct from an uintptr and print it to the console:
>>
>> certctx = (*CERT_CONTEXT) (unsafe.Pointer(pccert_context))
>> fmt.Printf("%v\n", certctx)
>> 
>> >&{1 807520 674 833008 789360}
>>
>> Any advise is warmly welcome.
>>
>> Cheers,
>> Sandro
>>
>

-- 
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: Mapping C pointer to BYTE to golang []byte

2017-12-14 Thread snmed
Okay I found a way, this seems to work:

ca := (*[100]byte) (unsafe.Pointer(certctx.pbCertEncoded))[:certctx.
cbCertEncoded]

or

mm := make([]byte, certctx.cbCertEncoded)
for i := uint32(0) ; i < certctx.cbCertEncoded; i++ {
mm[i] = *((*byte)(unsafe.Pointer(certctx.pbCertEncoded + uintptr(i) 
* unsafe.Sizeof(new(byte)
}



Anyway, the vet tool is complaining:

main.go:106: possible misuse of unsafe.Pointer
main.go:109: possible misuse of unsafe.Pointer

This is the code fragment:

104certctx := new(CERT_CONTEXT)
105
106certctx = (*CERT_CONTEXT) (unsafe.Pointer(pccert_context))
107
108
109ca := (*[100]byte) (unsafe.Pointer(certctx.pbCertEncoded))[:
certctx.cbCertEncoded]

Is there another way to use syscall return values uintptr without vet 
warnings? And which solution should I prefer? I think the later one should 
be more safe, isn't it?

Cheers


Am Donnerstag, 14. Dezember 2017 09:29:38 UTC+1 schrieb snmed:
>
> Hi Miki 
>
> I'm using syscall package and no C import, but maybe it is possible to use 
> this function as well?
>
> Am Donnerstag, 14. Dezember 2017 09:18:26 UTC+1 schrieb Miki Tebeka:
>>
>> Do you mean
>>
>> func C.GoBytes(unsafe.Pointer, C.int) []byte
>>
>>  ?
>>
>> On Thursday, December 14, 2017 at 9:05:32 AM UTC+2, snmed wrote:
>>>
>>> Hi all
>>>
>>> I'm trying to map a C structure to an equivalent go struct, but I bumped 
>>> into a problem with a pointer to byte that is actually an array of bytes.
>>>
>>> Here is the C struct:
>>>
>>> typedef struct _CERT_CONTEXT {
>>>   DWORD  dwCertEncodingType;
>>>   BYTE   *pbCertEncoded;
>>>   DWORD  cbCertEncoded;
>>>   PCERT_INFO pCertInfo;
>>>   HCERTSTORE hCertStore;
>>> } CERT_CONTEXT, *PCERT_CONTEXT;
>>>
>>>
>>> and this is my go struct:
>>>
>>> type CERT_CONTEXT struct {
>>> dwCertEncodingType uint32
>>> pbCertEncoded  uintptr
>>> cbCertEncoded  uint32
>>> pCertInfo  uintptr
>>> hCertStore uintptr
>>> }
>>>
>>> for my case I need only the first 3 fields and I do not have any problem 
>>> to get 1 and 3, but I can't remember how to translate the second field to a 
>>> slice of bytes.
>>> This is how I map the struct from an uintptr and print it to the console:
>>>
>>> certctx = (*CERT_CONTEXT) (unsafe.Pointer(pccert_context))
>>> fmt.Printf("%v\n", certctx)
>>> 
>>> >&{1 807520 674 833008 789360}
>>>
>>> Any advise is warmly welcome.
>>>
>>> Cheers,
>>> Sandro
>>>
>>

-- 
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] Profiling memory allocations for a function

2017-12-20 Thread snmed
Hi all

I struggling with profiling memory allocation for a function. I start the 
test with:

go test -run ^$ -bench Scanner -memprofile mem.out -cpuprofile cpu.out -
memprofilerate=1Code hier eingeben...

and then i use pprof with:

go tool pprof log.test.exe mem.out --alloc_space
top10 log\.\(\*scanner\)
Showing nodes accounting for 0, 0% of 62.91kB total
  flat  flat%   sum%cum   cum%



If I do the same with the cpu profile I getting results:

(pprof) top10 log\.\(\*scanner\)
Showing nodes accounting for 0.11s, 5.45% of 2.02s total
Showing top 10 nodes out of 25
  flat  flat%   sum%cum   cum%
 0.02s  0.99%  0.99%  0.03s  1.49%  runtime.lock C:\Go\src\runtime\
lock_sema.go
 0.02s  0.99%  1.98%  0.02s  0.99%  runtime.stkbucket C:\Go\src\
runtime\mprof.go
 0.02s  0.99%  2.97%  0.02s  0.99%  runtime.unlock C:\Go\src\runtime
\lock_sema.go
 0.01s   0.5%  3.47%  0.01s   0.5%  bitbucket.org/snmed/mw/log.(*
scanner).openToken C:\Projects\goworkspace\src\bitbucket.org\snmed\mw\log\
scanner.go
 0.01s   0.5%  3.96%  0.01s   0.5%  bitbucket.org/snmed/mw/log.(*
scanner).propIDToken C:\Projects\goworkspace\src\bitbucket.org\snmed\mw\log\
scanner.go
 0.01s   0.5%  4.46%  0.03s  1.49%  bitbucket.org/snmed/mw/log.(*
scanner).textToken C:\Projects\goworkspace\src\bitbucket.org\snmed\mw\log\
scanner.go
 0.01s   0.5%  4.95%  0.01s   0.5%  runtime.mallocgc C:\Go\src\
runtime\runtime1.go
 0.01s   0.5%  5.45%  0.01s   0.5%  runtime.stdcall2 C:\Go\src\
runtime\os_windows.go
 0 0%  5.45%  0.03s  1.49%  bitbucket.org/snmed/mw/log.(*
scanner).(bitbucket.org/snmed/mw/log.alignmentToken)-fm C:\Projects\
goworkspace\src\bitbucket.org\snmed\mw\log\scanner.go
 0 0%  5.45%  0.01s   0.5%  bitbucket.org/snmed/mw/log.(*
scanner).(bitbucket.org/snmed/mw/log.openToken)-fm C:\Projects\goworkspace\
src\bitbucket.org\snmed\mw\log\scanner.go

What I'm missing here, there must be some allocations because the benchmark 
shows me allocations:

goos: windows
goarch: amd64
pkg: butbucket.org/snmed/mw/log
BenchmarkScanner-830  4534 ns/op2864 B/op 
97 allocs/op
PASS
ok  butbucket.org/snmed/mw/log   1.618s

I'd appreciate any help.

Cheers
Sandro

-- 
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: concurrency programing about go

2017-11-02 Thread snmed
Hi 

Here is the code:

Version 1:
package main

import (
"fmt"
"sync"
)

var a string
var once sync.Once

func setup() {
a = "hello,world\n"
}
func doprint() {
once.Do(setup)
fmt.Print(a)
}
func twoprint() <-chan struct{} {
var wg sync.WaitGroup
wg.Add(2)
ch := make(chan struct{})

go func() {
doprint()
wg.Done()
}()
go func() {
doprint()
wg.Done()
}()

go func() {
wg.Wait()
close(ch)
}()

return ch
}

func main() {
ch := twoprint()
<-ch
}


Version 2:
package main

import (
"fmt"
"sync"
)

var a string
var once sync.Once

func setup() {
a = "hello,world\n"
}
func doprint() {
once.Do(setup)
fmt.Print(a)
}
func twoprint() {
var wg sync.WaitGroup
wg.Add(2)

go func() {
doprint()
wg.Done()
}()
go func() {
doprint()
wg.Done()
}()

wg.Wait()
}

func main() {
twoprint()
}


Cheers snmed


Am Donnerstag, 2. November 2017 10:37:15 UTC+1 schrieb 28911...@gmail.com:
>
> Sorry,I try my best to open the website but it can't work.Can you write it 
> ??Thank you so much.
>
> 在 2017年10月30日星期一 UTC+8下午4:29:44,snmed写道:
>>
>> Hi
>>
>> There are several ways to solve it, here are two of them:
>>
>> https://play.golang.org/p/wJwkI7HQwv
>> https://play.golang.org/p/nasUcgBeG4
>>
>> I prefer the first one, because so I can decide if i want to wait for the 
>> end of twoprint or not.
>>
>> Cheers
>>
>> Am Montag, 30. Oktober 2017 06:43:45 UTC+1 schrieb 28911...@gmail.com:
>>>
>>> Yes, you're right.So how to solve it??
>>>
>>> 在 2017年10月30日星期一 UTC+8下午12:37:49,Dave Cheney写道:
>>>>
>>>> Hello. I’m guessing that your tried calling twoprint(), but you’ve 
>>>> probably found that nothing is printed to the screen before your program 
>>>> exits. 
>>>>
>>>> Is that correct?
>>>
>>>

-- 
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: Webservices with Windows Authentication

2017-12-10 Thread snmed

Hi Paul

Thank you for your answer. Maybe i wasn't clear, but we do not have 
problems with direct user authentication, as we use ADFS and OAuth (Token 
format JWT) to authenticate users. Our problem is
the authentication between webservices and web applications that running 
under group managed service accounts (gMSA) and we strongly want to use 
that feature, because so we do not have to manage
passwords for those accounts. 

I found a kerberos library https://github.com/jcmturner/gokrb5 that looks 
very promising, but I do not know how to get a keytab for a group managed 
service account.

Cheers,
Sandro 

Am Sonntag, 10. Dezember 2017 01:51:11 UTC+1 schrieb oldCoderException:
>
> I can't comment on authenticating a go client against windoze services, 
> but we use both LDAP and Active Directory (AD) extensively and authenticate 
> our users, as well as add and modify them to those services using Go all 
> the time.  We use this excellent package:  
> https://godoc.org/gopkg.in/ldap.v2  and use straight LDAP calls both to 
> authenticate against and update AD.  All of our Go based web applications 
> allow our users to authenticate against any of multiple LDAP and AD servers 
> in a "federated fashion", trying the servers with the credentials 
> supplied.  Hope this helps.
>
> cheers,
> Paul
>
> On Saturday, 9 December 2017 14:59:41 UTC-8, snmed wrote:
>>
>> Hi all
>>
>> We are primarly working in a windows environment and developing web 
>> services as well as web applications. At the moment we're using C# as our 
>> main language, but we consider to
>> switch to go for the web services. There is one major uncertainty which 
>> hinders us to proceed with our idea, we using Group Managed Service 
>> Accounts to authenticate applications and 
>> services. Therefore we need to handle windows authentication on server 
>> and client side. 
>>
>> Has anyone a similar use case and has already solved it? Is there a well 
>> documented package which can be used to protect a http.Handler and verify a 
>> user with windows authentication?
>> And is there a package that can be used to authenticate a go client 
>> against a service which is protected with windows authentication.
>>
>> Any help or advise is warmly welcome.
>>
>> Cheers
>>
>

-- 
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: Webservices with Windows Authentication

2017-12-10 Thread snmed
Hi Mike

Thank you for the links, they are looking interesting. I will have a deeper 
look into it and try to build a working example.

Cheers
Sandro

Am Sonntag, 10. Dezember 2017 04:22:43 UTC+1 schrieb ancientlore:
>
> I haven't done it, but these two might be a starting point.
>
> https://github.com/Azure/go-ntlmssp
> https://github.com/ThomsonReutersEikon/go-ntlm 
> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2FThomsonReutersEikon%2Fgo-ntlm=D=1=AFQjCNGmPLiRsJ_mi2PmXY8RFjVKscoqOg>
>
> Mike
>
> On Saturday, December 9, 2017 at 5:59:41 PM UTC-5, snmed wrote:
>>
>> Hi all
>>
>> We are primarly working in a windows environment and developing web 
>> services as well as web applications. At the moment we're using C# as our 
>> main language, but we consider to
>> switch to go for the web services. There is one major uncertainty which 
>> hinders us to proceed with our idea, we using Group Managed Service 
>> Accounts to authenticate applications and 
>> services. Therefore we need to handle windows authentication on server 
>> and client side. 
>>
>> Has anyone a similar use case and has already solved it? Is there a well 
>> documented package which can be used to protect a http.Handler and verify a 
>> user with windows authentication?
>> And is there a package that can be used to authenticate a go client 
>> against a service which is protected with windows authentication.
>>
>> Any help or advise is warmly welcome.
>>
>> Cheers
>>
>

-- 
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: concurrency programing about go

2017-10-30 Thread snmed
Hi

There are several ways to solve it, here are two of them:

https://play.golang.org/p/wJwkI7HQwv
https://play.golang.org/p/nasUcgBeG4

I prefer the first one, because so I can decide if i want to wait for the 
end of twoprint or not.

Cheers

Am Montag, 30. Oktober 2017 06:43:45 UTC+1 schrieb 28911...@gmail.com:
>
> Yes, you're right.So how to solve it??
>
> 在 2017年10月30日星期一 UTC+8下午12:37:49,Dave Cheney写道:
>>
>> Hello. I’m guessing that your tried calling twoprint(), but you’ve 
>> probably found that nothing is printed to the screen before your program 
>> exits. 
>>
>> Is that correct?
>
>

-- 
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: Struct members, hide or export?

2018-08-09 Thread snmed
Hi

I would suggest to use the second option. If you export all possible 
members, you have to care on every redesign who and how this members are 
used. This makes a redesign unnecessarily tricky.
Constructor functions are a common pattern in go code and therefore you 
should not flinch to use it. For testing you can append "_test" to the 
package name and then your test can't see any non exportet members of your 
package.

Cheers
Sandro

Am Donnerstag, 9. August 2018 09:50:55 UTC+2 schrieb Jay G:
>
> Let's say I'm writing some library for internal usage in my project, 
> what's the idiomatic way to design visibility of struct members?
>
>- Option 1. export structs and members as much as possible. Only hide 
>ones that need to be protected, e.g. by a lock
>- Option 2. hide as much as possible. Only export when necessary
>
> *Opt 1 makes testing easier when written in separate pkg. Also we don't 
> rely on constructors to inject dependencies*
> *Opt 2 defines a clearer API, and prevent users from accessing unnecessary 
> fields, which could be prone of error*
>
>
> Is constructor actually anti-pattern in Go?
>
> type Foo struct {
>   A A
>   B B
> }
>
>
> func main() {
>   _ := {A: myA, B: myB}
> }
>
> vs
>
> type Foo struct {
>   a A
>   b B
> }
>
>
> func NewFoo(a A, b B) *Foo {
>   return {a: a, b: b}
> }
>
>
> func main() {
>   _ := NewFoo(myA, myB)
> }
>
>
> thanks a lot!
> - 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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] TLS mutual auth: trusting a single client certificate?

2018-01-23 Thread snmed
Hi

As far as I understand, you can set this function 
VerifyPeerCertificate in the tls config and then verify the thumbprint of the 
client certificate. This method is only called, when the client has a valid 
certificate.

Cheers
Sandro

-- 
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: constructors vs lazy initialization

2018-03-11 Thread snmed
But this is only working as long as you do not need any services or 
dependencies. And in that case i would really appreciate if the language 
natively supports a nil check on method parameters at compile time.
For all cases where nil is a valid value, the language needs a marker to 
allow such cases. In my opinion it would save some nil checks and makes it 
much more clear for the caller what the method is expecting.



Am Sonntag, 4. März 2018 04:20:11 UTC+1 schrieb Dave Cheney:
>
> I prefer the later when possible because it enables callers to use the 
> zero value of a type without explicit initialisation.
>
> On Sunday, 4 March 2018 11:37:43 UTC+11, Anmol Sethi wrote:
>>
>> How do you guys choose between constructors and lazy initialization?
>>
>> For example.
>>
>> Struct constructors:
>>
>> type meow struct {
>> x http.Handler
>> }
>>
>> func newMeow() *meow {
>> return {
>> x: http.NewServeMux(),
>> }
>> }
>>
>> func (m *meow) do() {
>> // stuff
>> }
>>
>>
>> Lazy initialization:
>>
>> type meow struct {
>> x http.Handler
>> }
>>
>> func (m *meow) do() {
>> if m.x == nil {
>> m.x = http.NewServeMux()
>> }
>> // stuff
>> }
>>
>>

-- 
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] Statically compile and link a go program with C dependencies

2019-01-21 Thread snmed
Hi all 

I try to compile and statically link the following example: 
https://github.com/rthornton128/goncurses/tree/master/examples/curs_menu
I use this command:
go build -ldflags '-w -extldflags "-static"' -a

Unfortunately i get only this:
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1

/usr/bin/ld: cannot find -lformw

/usr/bin/ld: cannot find -lmenuw

/usr/bin/ld: cannot find -lncursesw

/usr/bin/ld: cannot find -lpanelw

collect2: error: ld returned 1 exit status



I have verified that all necessary libs are under /lib64, but the linker 
still complains. I'd appreciate any clues on this topic.

Cheers,

-- 
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] Statically compile and link a go program with C dependencies

2019-01-21 Thread snmed
Hi thanks,

Ah yes, it seems that i forgot that with the static library. Now i've the 
static library under ./libs folder and i use this command:
go build -ldflags '-L./libs -w -extldflags "-static"' -a

but now i get this message:
flag provided but not defined: -L./libs

usage: link [options] main.o

  -B note

add an ELF NT_GNU_BUILD_ID note when using ELF

  -D address

set data segment address (default -1)

  -E entry

set entry symbol name

  -H type

set header type

  -I linker

...rest omitted for brevity

am i using the command wrong or is there a flag i'm missing?

Am Montag, 21. Januar 2019 17:40:54 UTC+1 schrieb Kurtis Rader:
>
> You say you "verified that all necessary libs are under /lib64." Do you 
> actually have static versions of those libraries or just dynamic versions? 
> For example, on macOS I only have dynamic (ending in .dylib) versions so it 
> isn't possible to statically link a binary that requires those libraries. 
> The "file" command should tell you whether the library is dynamic or 
> static. But in general a static lib will have a ".a" extension and dynamic 
> libs will have a ".so" or ".dylib" extension. "In general" because this is 
> platform dependent and you could be working on a platform with different 
> conventions.
>
> On Mon, Jan 21, 2019 at 7:50 AM snmed > 
> wrote:
>
>> Hi all 
>>
>> I try to compile and statically link the following example: 
>> https://github.com/rthornton128/goncurses/tree/master/examples/curs_menu
>> I use this command:
>> go build -ldflags '-w -extldflags "-static"' -a
>>
>> Unfortunately i get only this:
>> /usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
>>
>> /usr/bin/ld: cannot find -lformw
>>
>> /usr/bin/ld: cannot find -lmenuw
>>
>> /usr/bin/ld: cannot find -lncursesw
>>
>> /usr/bin/ld: cannot find -lpanelw
>>
>> collect2: error: ld returned 1 exit status
>>
>>
>>
>> I have verified that all necessary libs are under /lib64, but the linker 
>> still complains. I'd appreciate any clues on this topic.
>>
>> Cheers,
>>
>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
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] Go offline development recommendations

2018-12-12 Thread snmed
Hi all

Our customer demands an offline development environment with no internet 
connection, is there any best practices to handle package download and 
project setup for such an use case? And how would the new go modules fit in 
in such an environment?

Any advise will be most appreciated.

Cheers Sandro

-- 
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 offline development recommendations

2018-12-12 Thread snmed
Hi thepudds

Thanks for you Reply. Indeed vendoring is an Option, but I'm not sure how 
long that will be supported. I think i've read about a blog post which says 
vendoring will be remove from the go tools, but i'm not sure if this still 
on the Roadmap of the go Team.
I will have a look into the walkthrough you've posted and see if i get some 
new ideas out of it.

Cheers

Am Mittwoch, 12. Dezember 2018 22:35:36 UTC+1 schrieb thepud...@gmail.com:
>
> Hi Sandro,
>
> Vendoring is another approach that can work here.
>
> In a pre-modules world, vendoring is fairly well known.
>
> In a modules world, vendoring is still an option. For example, you can see 
> this FAQ here that touches on using 'go mod vendor' with modules:
>
> 
> https://github.com/golang/go/wiki/Modules#how-do-i-use-vendoring-with-modules-is-vendoring-going-away
>
> An alternative approach in a modules world is to use the module cache. It 
> can end up with similar benefits as traditional vendoring (and in some ways 
> ends up with a higher fidelity copy), but uses a different technique. This 
> approach is explained as a "Go Modules by Example" walkthrough here:
>
> 
> https://github.com/go-modules-by-example/index/blob/master/012_modvendor/README.md
>
> Best,
> thepudds
>
> On Wednesday, December 12, 2018 at 3:52:58 PM UTC-5, snmed wrote:
>>
>> Thank you for you reply,
>>
>> yes i have already read about that project, but as far as I see, there is 
>> no offline loading implemented.
>> But I'm sure it would be doable with some customisation. I wondering if 
>> there is another approach for an offline scenario.
>>
>> Some other ideas or suggestions?
>>
>> Thanks in advance
>> Sandro
>>
>> Am Mittwoch, 12. Dezember 2018 21:04:07 UTC+1 schrieb Burak Serdar:
>>>
>>> On Wed, Dec 12, 2018 at 1:00 PM snmed  wrote: 
>>> > 
>>> > Hi all 
>>> > 
>>> > Our customer demands an offline development environment with no 
>>> internet connection, is there any best practices to handle package download 
>>> and project setup for such an use case? And how would the new go modules 
>>> fit in in such an environment? 
>>>
>>> Somebody just mentioned this today. It looks like it is doing what 
>>> you're asking for: 
>>>
>>> https://github.com/gomods/athens 
>>>
>>>
>>> > 
>>> > Any advise will be most appreciated. 
>>> > 
>>> > Cheers Sandro 
>>> > 
>>> > -- 
>>> > 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...@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 offline development recommendations

2018-12-12 Thread snmed
Hi Tom

Thanks for your input. Generally speaking, the overall process how to 
handle development in an air gapped environment is clear and also how i can 
identify the required files. My question was more about best practices to 
handle such situation for go project.
At the moment i favour athens as proxy and try to preload all required 
packages some how.



Am Mittwoch, 12. Dezember 2018 22:19:14 UTC+1 schrieb Tom Mitchell:
>
>
> On Wed, Dec 12, 2018 at 12:00 PM snmed > 
> wrote:
>
>> Hi all
>>
>> Our customer demands an offline development environment with no internet 
>> connection, is there any best practices to handle package download and 
>> project setup for such an use case? And how would the new go modules fit in 
>> in such an environment?
>>
>> Any advise will be most appreciated.
>>
>
> Such a requirement can only be addressed with an air gap bridge.
> Are they working with Linux or another platform?
>
> On linux  it is easy to "touch /var/tmp/now"  and "find / -newer 
> /var/tmp/now"
> and collect anything that is pulled in locally.  then burn selected  bits 
> to a CDROM.
>
> Users inside the offline isolation booth have to make requests for library 
> and module
> source or binaries and communicate possibly with paper for the bits they 
> need.
> Dummy, stub programs will make it easy to identify and trigger the 
> downloads of objects. 
> No USB sticks...
>
> The CDROM set is an audit trail and allows virus scanning.   
>
> The same is true for any and all system services libraries and more inside 
> the development environment.
> That off line development  environment likely needs exactly the same or 
> stricter audit and reproducible setup.
> At each release cycle and checkpoint for debugging ... so leverage that 
> same audit and management
> systematic process.   
>
> Their ask is bigger than golang.
>
>
>
>
>
>
>
> -- 
>T o mM i t c h e l l
>

-- 
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 offline development recommendations

2018-12-12 Thread snmed
Thank you for you reply,

yes i have already read about that project, but as far as I see, there is 
no offline loading implemented.
But I'm sure it would be doable with some customisation. I wondering if 
there is another approach for an offline scenario.

Some other ideas or suggestions?

Thanks in advance
Sandro

Am Mittwoch, 12. Dezember 2018 21:04:07 UTC+1 schrieb Burak Serdar:
>
> On Wed, Dec 12, 2018 at 1:00 PM snmed > 
> wrote: 
> > 
> > Hi all 
> > 
> > Our customer demands an offline development environment with no internet 
> connection, is there any best practices to handle package download and 
> project setup for such an use case? And how would the new go modules fit in 
> in such an environment? 
>
> Somebody just mentioned this today. It looks like it is doing what 
> you're asking for: 
>
> https://github.com/gomods/athens 
>
>
> > 
> > Any advise will be most appreciated. 
> > 
> > Cheers Sandro 
> > 
> > -- 
> > 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...@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 offline development recommendations

2018-12-12 Thread snmed
Thank you very much for your reply. It seems to be a possible way to do it, 
what do you think about the athens way? In my point of view it would be the 
easiest way as far i can preload the athens cache with all the required 
packages,
And then the only thing a developer has to do, is to set the GOPROXY to the 
athens instance.

Cheers

Am Mittwoch, 12. Dezember 2018 23:51:08 UTC+1 schrieb ohir:
>
> On Wed, 12 Dec 2018 11:59:59 -0800 (PST) 
> snmed > wrote: 
>
> > Hi all 
> > 
> > Our customer demands an offline development environment with no internet 
> > connection, is there any best practices to handle package download and 
> > project setup for such an use case? 
>
> Such setups are supported by the Go from its onset. 
>
> 1. DMZ box where `go get` can reach external repositories 
> 2. IDP internal distribution point - with vetted go tools and vetted libs 
>
> External downloads are done via the DMZ box then inspected. 
> After security team OK's something it is moved to the IDP 
> host from where devs ro mount: 
>
> Std tools and libs - to the fixed GOROOT location, say /usr/local/go 
>
> Vetted internal libs - to the fixed main GOPATH location, say 
> /usr/local/gours [1] 
>
> Vetted third party libs - to the second GOPATH location, say 
>  /usr/local/go3p. 
>
> Local development takes place in the third GOPATH location, 
> say /home/${USER}/project/go 
>
> On the dev box: 
>
> # GOROOT=; not set - it is present in the tools via GOROOT_FINAL 
> # GOPATH=/internal:/thirdparty:/local [2] 
> export GOPATH=/usr/local/gours:/usr/local/go3p:/home/${USER}/project/go 
>
> [1] Authors of internal libs usually work on shadowmount within 
> this path, then commit to the reviewers repo from where their vetted 
> lib goes to the IDP. 
>
> [2] Accidental `go get` of some privileged (or in sec rules violation) 
> person 
> will try to write to the first "/internal" path where either it errs 
> because its read only 
> or at most it will write to the local disk - then shadowed by the remote 
> mount. 
>
> read `go help gopath` for details. 
>
>
> > And how would the new go modules fit in 
> > in such an environment? 
>
> It does not AFAICS. I can not elaborate on this due to the list's CoC. 
> I just hope that Go team ultimately will not pull GOPATH from under our 
> feet. 
>
> > Any advise will be most appreciated. 
>
> Hope this helps, 
>
>
> -- 
> Wojciech S. Czarnecki 
>  << ^oo^ >> OHIR-RIPE 
>

-- 
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 offline development recommendations

2018-12-13 Thread snmed
I'm not sure if i fully understand your point on "vetted binaries", but if 
every source code is vetted and then transferred to the isolated 
environment, there should not be a problem with security issues. All the 
developer machine living already in the same isolated environment and also 
i would place athens there, so all builds will be made with vetted source 
code. 

It's easily possible that i miss some import point in this scenario, but 
anyway i will verify your idea and take it into account for our go 
development strategy.

Am Donnerstag, 13. Dezember 2018 10:38:30 UTC+1 schrieb ohir:
>
> On Wed, 12 Dec 2018 22:15:23 -0800 (PST) 
> snmed > wrote: 
>
> > Thank you very much for your reply. It seems to be a possible way to do 
> it, 
> > what do you think about the athens way? 
>
> From the secop pov it'll be a hells gate. Also it does not allow for 
> vetted binary arifacts as current unix/Go ways do. 
>
> > what do you think about the athens way? 
>
> 1) Athens is in flux. 2) It is yet another complicated piece of software 
> to analyze and monitor. 3) It again brings all compiling to the local 
> machine while GOPATH way allows all devs to use binary artifacts built 
> on the hardened builder machine. 
>
> > In my point of view it would be the easiest way as far i can preload the 
> > athens cache with all the required packages. 
>
> So the security team will need to produce an internal vetted package 
> instead 
> of signing a tag within the IDP 3rd party package repo. 
>
> (IMO whole idea of "zipped packages" is the bad J-flu infection... Ah - 
> CoC) 
>
> > And then the only thing a developer has to do, is to set the GOPROXY to 
> the 
> > athens instance. 
>
> It fits loose distributed settings. Not controlled ones. And I -- from 
> "offline"/"airgap" constraint -- assumed that your client is concerned 
> about 
> security, not about connectivity. 
>
> Hope this helps, 
>
> -- 
> Wojciech S. Czarnecki 
>  << ^oo^ >> OHIR-RIPE 
>
>

-- 
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 offline development recommendations

2018-12-13 Thread snmed
Indeed vendoring is a possible way we will consider that option but with go 
mod instead with dep. I strongly believe that the module way go is heading 
is the right way, but i'd like to have more documentation about using go 
modules in an air gapped network environment.

Anyway thank you for your input

Am Freitag, 14. Dezember 2018 02:25:14 UTC+1 schrieb Nathan Fisher:
>
> We use dep at work and commit the vendor folder. The main benefit we see 
> is that it ensures consistent builds across machines, tends to be faster, 
> and allows offline development. assuming you don’t have to use a third 
> party security or infrastructure team to download the dependencies. If you 
> do then it can be a bit of a nuisance because they need the tooling on 
> their machine. Committing the vendor folder is a lot less effort than 
> alternative solutions from my experience in similarly restrictive 
> environments.
> On Thu, Dec 13, 2018 at 09:00, akshita babel  > wrote:
>
>> Hey, can anyone guide me on how to take octet stream as input in API 
>> and/or how to convert octet stream to byte array using golang
>>
>> On Thu, Dec 13, 2018 at 5:14 PM snmed > 
>> wrote:
>>
>>> I'm not sure if i fully understand your point on "vetted binaries", but 
>>> if every source code is vetted and then transferred to the isolated 
>>> environment, there should not be a problem with security issues. All the 
>>> developer machine living already in the same isolated environment and also 
>>> i would place athens there, so all builds will be made with vetted source 
>>> code. 
>>>
>>> It's easily possible that i miss some import point in this scenario, but 
>>> anyway i will verify your idea and take it into account for our go 
>>> development strategy.
>>>
>>> Am Donnerstag, 13. Dezember 2018 10:38:30 UTC+1 schrieb ohir:
>>>>
>>>> On Wed, 12 Dec 2018 22:15:23 -0800 (PST) 
>>>> snmed  wrote: 
>>>>
>>>> > Thank you very much for your reply. It seems to be a possible way to 
>>>> do it, 
>>>> > what do you think about the athens way? 
>>>>
>>>> From the secop pov it'll be a hells gate. Also it does not allow for 
>>>> vetted binary arifacts as current unix/Go ways do. 
>>>>
>>>> > what do you think about the athens way? 
>>>>
>>>> 1) Athens is in flux. 2) It is yet another complicated piece of 
>>>> software 
>>>> to analyze and monitor. 3) It again brings all compiling to the local 
>>>> machine while GOPATH way allows all devs to use binary artifacts built 
>>>> on the hardened builder machine. 
>>>>
>>>> > In my point of view it would be the easiest way as far i can preload 
>>>> the 
>>>> > athens cache with all the required packages. 
>>>>
>>>> So the security team will need to produce an internal vetted package 
>>>> instead 
>>>> of signing a tag within the IDP 3rd party package repo. 
>>>>
>>>> (IMO whole idea of "zipped packages" is the bad J-flu infection... Ah - 
>>>> CoC) 
>>>>
>>>> > And then the only thing a developer has to do, is to set the GOPROXY 
>>>> to the 
>>>> > athens instance. 
>>>>
>>>> It fits loose distributed settings. Not controlled ones. And I -- from 
>>>> "offline"/"airgap" constraint -- assumed that your client is concerned 
>>>> about 
>>>> security, not about connectivity. 
>>>>
>>>> Hope this helps, 
>>>>
>>>> -- 
>>>> Wojciech S. Czarnecki 
>>>>  << ^oo^ >> OHIR-RIPE 
>>>>
>>>> -- 
>>> 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...@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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
> - sent from my mobile
>

-- 
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] C Third Party Lib CGO

2021-07-07 Thread snmed

Hi all

Once again I have a 3th party library which looks like this example: 
https://play.golang.org/p/Ue9yQ8s8Ymq and I need it to integrate in our go 
tool. The example is working but is still get the warning "
possible misuse of unsafe.Pointer". 

So my questions are:

   1. Can I use uintptr to hold the void pointer and pass it around go 
   functions?
   2. Can I ignore the warning "possible misuse of unsafe.pointer"?
   3. If not, what would be the proper approach for this example?

Any help is much appreciated...
Sandro


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/964e1e57-ff6f-4f3e-8f40-981a3966e734n%40googlegroups.com.


[go-nuts] Re: C Third Party Lib CGO

2021-07-08 Thread snmed
Thanks for your reply. I came across a similar solution today, I made a 
struct which is visible outside the package and use a private field myApp 
C.MyAppPtr to hide the C type.
I still wondering why the uintptr version works but shows a warning 
"possible misuse of unsafe.pointer", CGO documentation is not very clear to 
me about the intricacies of type conversions between Go and C.

Cheers

Tamás Gulácsi schrieb am Donnerstag, 8. Juli 2021 um 16:52:01 UTC+2:

> Use *C.MyAppPtr on Go side, don't hide it behind an uintptr.
>
> snmed a következőt írta (2021. július 7., szerda, 19:47:44 UTC+2):
>
>>
>> Hi all
>>
>> Once again I have a 3th party library which looks like this example: 
>> https://play.golang.org/p/Ue9yQ8s8Ymq and I need it to integrate in our 
>> go tool. The example is working but is still get the warning "
>> possible misuse of unsafe.Pointer". 
>>
>> So my questions are:
>>
>>1. Can I use uintptr to hold the void pointer and pass it around go 
>>functions?
>>2. Can I ignore the warning "possible misuse of unsafe.pointer"?
>>3. If not, what would be the proper approach for this example?
>>
>> Any help is much appreciated...
>> Sandro
>>
>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d4a60409-e9e1-4bba-b09d-34c03876eef9n%40googlegroups.com.


Re: [go-nuts] Re: C Third Party Lib CGO

2021-07-09 Thread snmed
Yes uintptr is the address the C pointer is pointing to , right? So C 
doesn't move any memory and therefore the address is still valid until 
deleted in C code.
If I take the value of uintptr variable,  convert it back with 
unsafe.Pointer(uintptr) and pass it to a C function, does C not interpret 
that as a C pointer pointing to the same address as uintptr holds?
Therefore the conversion should be alright?

Sorry for not getting it...

Sandro

Tamás Gulácsi schrieb am Freitag, 9. Juli 2021 um 11:12:22 UTC+2:

> An uintptr *is not a pointer*, so 2. is false.
> NOTHING at Go's side holds anything regarding MyAppHwnd, and it doesn't 
> seem to be a pointer at all (just a number),
> so converting that to an unsafe.Pointer is unsafe.
>
> The rules about uintptr are there for a reason!
> Only the allowed use cases are guaranteed to have the desired effect, by 
> preventing any memory movement
> int that block of code.
>
> Tamas
> snmed a következőt írta (2021. július 9., péntek, 8:21:37 UTC+2):
>
>> Thx Ian to pointing me to the documentation I read it, but still unsure 
>> regarding my example. Probably rule number 4 could apply, so let me go 
>> through my example and correct me if I'm wrong.
>>
>> 1. C.CreateApp() creates memory in C code and returns it as  C void 
>> pointer
>> 2. Go function CreateApp() returns that as MyAppHwnd (uintptr ) so 
>> MyAppHwnd contains a valid C memory address
>> 3. app variable holds still a valid C memory address as long as it is not 
>> deleted in C code
>> 4. So calling ShowApp() it should be legit to convert MyAppHwnd  back to 
>> an unsafe.Pointer and cast it to C.MyAppPtr. It is still a valid memory 
>> address in C and therefore should be interpreted as pointer in C, right?
>>
>> So therefore the warning can be ignored or do I miss something important?
>>
>> Cheers
>> Sandro
>>
>>
>> Ian Lance Taylor schrieb am Freitag, 9. Juli 2021 um 05:37:16 UTC+2:
>>
>>> On Thu, Jul 8, 2021 at 10:09 AM snmed  wrote: 
>>> > 
>>> > Thanks for your reply. I came across a similar solution today, I made 
>>> a struct which is visible outside the package and use a private field myApp 
>>> C.MyAppPtr to hide the C type. 
>>> > I still wondering why the uintptr version works but shows a warning 
>>> "possible misuse of unsafe.pointer", CGO documentation is not very clear to 
>>> me about the intricacies of type conversions between Go and C. 
>>>
>>> There is a very limited number of cases in which it is OK to convert a 
>>> pointer to uintptr. Those cases are described at 
>>> https://golang.org/pkg/unsafe. 
>>>
>>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e6e655f5-bf38-4d82-80d8-259a054e9138n%40googlegroups.com.


Re: [go-nuts] Re: C Third Party Lib CGO

2021-07-09 Thread snmed
Okay,  will store the pointer directly in a struct as a private field.

Thanks for your time and input, I greatly appreciate it.


Tamás Gulácsi schrieb am Freitag, 9. Juli 2021 um 14:17:48 UTC+2:

> The runtime and checks does not know what's inside an uintptr, so 
> converting an uintptr to a(n unsafe.)Pointer
> triggers the warnings. Only the special specified cases are legal.
>
> TL;DR; Do not use uintptr.
> (More elaborate: do not use an uintptr to store and retrieve a pointer - 
> just store the pointer directly).
>
> Tamas
>
> snmed a következőt írta (2021. július 9., péntek, 11:26:48 UTC+2):
>
>> Yes uintptr is the address the C pointer is pointing to , right? So C 
>> doesn't move any memory and therefore the address is still valid until 
>> deleted in C code.
>> If I take the value of uintptr variable,  convert it back with 
>> unsafe.Pointer(uintptr) and pass it to a C function, does C not interpret 
>> that as a C pointer pointing to the same address as uintptr holds?
>> Therefore the conversion should be alright?
>>
>> Sorry for not getting it...
>>
>> Sandro
>>
>> Tamás Gulácsi schrieb am Freitag, 9. Juli 2021 um 11:12:22 UTC+2:
>>
>>> An uintptr *is not a pointer*, so 2. is false.
>>> NOTHING at Go's side holds anything regarding MyAppHwnd, and it doesn't 
>>> seem to be a pointer at all (just a number),
>>> so converting that to an unsafe.Pointer is unsafe.
>>>
>>> The rules about uintptr are there for a reason!
>>> Only the allowed use cases are guaranteed to have the desired effect, by 
>>> preventing any memory movement
>>> int that block of code.
>>>
>>> Tamas
>>> snmed a következőt írta (2021. július 9., péntek, 8:21:37 UTC+2):
>>>
>>>> Thx Ian to pointing me to the documentation I read it, but still unsure 
>>>> regarding my example. Probably rule number 4 could apply, so let me go 
>>>> through my example and correct me if I'm wrong.
>>>>
>>>> 1. C.CreateApp() creates memory in C code and returns it as  C void 
>>>> pointer
>>>> 2. Go function CreateApp() returns that as MyAppHwnd (uintptr ) so 
>>>> MyAppHwnd contains a valid C memory address
>>>> 3. app variable holds still a valid C memory address as long as it is 
>>>> not deleted in C code
>>>> 4. So calling ShowApp() it should be legit to convert MyAppHwnd  back 
>>>> to an unsafe.Pointer and cast it to C.MyAppPtr. It is still a valid memory 
>>>> address in C and therefore should be interpreted as pointer in C, right?
>>>>
>>>> So therefore the warning can be ignored or do I miss something 
>>>> important?
>>>>
>>>> Cheers
>>>> Sandro
>>>>
>>>>
>>>> Ian Lance Taylor schrieb am Freitag, 9. Juli 2021 um 05:37:16 UTC+2:
>>>>
>>>>> On Thu, Jul 8, 2021 at 10:09 AM snmed  wrote: 
>>>>> > 
>>>>> > Thanks for your reply. I came across a similar solution today, I 
>>>>> made a struct which is visible outside the package and use a private 
>>>>> field 
>>>>> myApp C.MyAppPtr to hide the C type. 
>>>>> > I still wondering why the uintptr version works but shows a warning 
>>>>> "possible misuse of unsafe.pointer", CGO documentation is not very clear 
>>>>> to 
>>>>> me about the intricacies of type conversions between Go and C. 
>>>>>
>>>>> There is a very limited number of cases in which it is OK to convert a 
>>>>> pointer to uintptr. Those cases are described at 
>>>>> https://golang.org/pkg/unsafe. 
>>>>>
>>>>> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/b63866bd-d536-477c-bc7b-43cf791f4490n%40googlegroups.com.


Re: [go-nuts] Re: C Third Party Lib CGO

2021-07-09 Thread snmed
Thx Ian to pointing me to the documentation I read it, but still unsure 
regarding my example. Probably rule number 4 could apply, so let me go 
through my example and correct me if I'm wrong.

1. C.CreateApp() creates memory in C code and returns it as  C void pointer
2. Go function CreateApp() returns that as MyAppHwnd (uintptr ) so 
MyAppHwnd contains a valid C memory address
3. app variable holds still a valid C memory address as long as it is not 
deleted in C code
4. So calling ShowApp() it should be legit to convert MyAppHwnd  back to an 
unsafe.Pointer and cast it to C.MyAppPtr. It is still a valid memory 
address in C and therefore should be interpreted as pointer in C, right?

So therefore the warning can be ignored or do I miss something important?

Cheers
Sandro


Ian Lance Taylor schrieb am Freitag, 9. Juli 2021 um 05:37:16 UTC+2:

> On Thu, Jul 8, 2021 at 10:09 AM snmed  wrote:
> >
> > Thanks for your reply. I came across a similar solution today, I made a 
> struct which is visible outside the package and use a private field myApp 
> C.MyAppPtr to hide the C type.
> > I still wondering why the uintptr version works but shows a warning 
> "possible misuse of unsafe.pointer", CGO documentation is not very clear to 
> me about the intricacies of type conversions between Go and C.
>
> There is a very limited number of cases in which it is OK to convert a
> pointer to uintptr. Those cases are described at
> https://golang.org/pkg/unsafe.
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/72ea6248-f845-45c4-94b9-fab7027a60b2n%40googlegroups.com.


[go-nuts] Tool go-offline-packager

2021-02-28 Thread snmed

Hi all

If anyone is interested, i made a little tool to download and package go 
modules for air-gapped environments.

Here the link to the repo: https://github.com/go-sharp/go-offline-packager

Any comments or suggestions are most welcome.

Cheers,
Sandro

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f170b9c4-3299-4b62-a11c-7fd97d907600n%40googlegroups.com.


[go-nuts] XML Schema Validation

2021-10-12 Thread snmed
Hi there,

I wondering why there is no pure XML Schema validation library in go or 
even in the go std.
Is there any best practice to validate xml schemas in go?

Cheers,
Sandro

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8fcc0b79-2ab6-4bab-8426-12d98dff39ddn%40googlegroups.com.


[go-nuts] Re: Logging in to web services

2021-10-12 Thread snmed
Hi Denis,

I'm not sure if I understand your question correctly, but it seems to me 
that you need a context with user specific data. Therefore, I would create 
a handler that will add the current user to the context and then you can 
access it in every handler where you need it. User of your site must be 
identified by a token or cookie, normally this also known as session 
handling. There are several libraries that can be used for such kind of 
task see:

- https://pkg.go.dev/github.com/gorilla/sessions
- https://github.com/alexedwards/scs

Keep in mind that you do not store sensitive data in cookies, user 
identities must be kept on server and stored in a save manner.
One can use signed JWT tokens to store an users identity within the clients 
browser. 

Hope this helps

Cheers

muhorto...@gmail.com schrieb am Dienstag, 12. Oktober 2021 um 10:28:00 
UTC+2:

> Hi, I have a question that is difficult for me to describe, but at the 
> level of fundamental questions about creating a web service. I have a 
> problem that if a user logs into a profile, then another user will also get 
> into his profile. Generally speaking, this is the property of any person 
> who visits the site. I see a solution to the problem in two ways. I do not 
> know if it is possible to somehow track connections and give each IP its 
> own routine in which it worked. Or dynamic pages that can only be accessed 
> if the request is successful. But again, some data in the structures may 
> change due to another user logged into the profile. Maybe there is some 
> other solution to this problem. I want to understand how it works on the 
> web.
> My project just in case: https://github.com/MukhortovDenis/goproject
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/9ac34974-ad5e-4705-ba67-380ddcca1ca4n%40googlegroups.com.