[go-nuts] Issue with golang.design/x/clipboard

2024-03-09 Thread Arie van Wingerden
See my code attached!

My issue is that, after writing to the clipboard, I can only read the 
string I wrote back during the period I "sleep" after the write.

If I do not sleep, the clipboard immediately reverts to "empty".

Am I doing something wrong here?

TIA
Arie

-- 
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/a6325fba-098e-4e42-ac4e-003d270fc3a0n%40googlegroups.com.
package main

import (
	"fmt"
	"time"

	"golang.design/x/clipboard"
)

var users = map[string]string{
	"u1": "elephant",
	"u2": "tiger",
}

func main() {

	user := users["u1"]
	fmt.Printf("Users..: %v\n", users)
	fmt.Printf("Selected User..: %s\n", user)

	err := clipboard.Init()
	if err != nil {
		panic(err)
	}

	clipboard.Write(clipboard.FmtText, []byte(user))
	
	// While sleeping, I can paste the clipboard content ("elephant¨)
	// in a separate running text editor.
	
	// But, when this program is finished, the clipboard appears to be
	// empty! Why is that?
	
	time.Sleep(10 * time.Second)

	fmt.Println("Ready!")

}


[go-nuts] Issue with integration test coverage

2023-07-11 Thread savita juyal
Hello All,

I am trying to collect integration test coverage but its not generating 
covcounters file. Please looks steps I am following to generate covearge.

- *Build go binary* : go build -race -*cover* -o $(ROOT)/go/bin/appwithrace 
-ldflags "-X app/handler.proxyVersion=$(VERSION) -X 
app/handler.gitVersion=$(GITVERSION) -X app/handler.buildTime=$(BUILDTIME)" 
cmd/proxy/proxy.go

- *Run go binary* : ENABLE_TLS=false ENABLE_TLS_TO_DB=false 
LOAD_BALANCED=false *GOCOVERDIR=./coverage/int *./go/bin/appwithrace 2>&1 
>/dev/null &

- *Exit go program* : Kill -9 go_process_id

Now we only covmetadata file generated under the given path. Please me know 
what I am doing wrong or if I am missing something?

Regards
Savita Juyal





-- 
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/150507ef-7245-40f1-a9c1-5128385d2874n%40googlegroups.com.


Re: [go-nuts] Issue with glog https://github.com/golang/glog/releases/tag/v1.1.0

2023-03-23 Thread chandra sekhar
Hi Chressie Himpel,
Fix works for me. Thanks for the quick response. 

Regards,
Chandra R

On Wednesday, March 22, 2023 at 6:08:17 PM UTC+2 Chressie Himpel wrote:

> On Mon, Mar 20, 2023 at 6:07 PM Chressie Himpel  
> wrote:
> >
> > On Mon, Mar 20, 2023 at 4:44 PM chandra sekhar  
> wrote:
> > >
> > > Hi,
> > > I see that you have already provided a fix for this issue 
> https://github.com/golang/glog/commit/9c9801e69114b582b12aa7010c75fe2105ae23b3
> .
> > > Any idea when you will make a new tag release with this fix?
> >
> > I have another fix in the pipeline that i would like to land before
> > tagging a new release. It should be a matter of a few days. Thanks for
> > your patience.
>
> I just tagged https://github.com/golang/glog/releases/tag/v1.1.1 that
> contains the fix.
>
> >
> > >
> > > Regards,
> > > Chandra R.
> > >
> > > On Thursday, March 16, 2023 at 9:17:20 PM UTC+2 Chressie Himpel wrote:
> > >>
> > >> On Thu, Mar 16, 2023 at 5:24 PM Ian Lance Taylor  
> wrote:
> > >> >
> > >> > [ + jba ]
> > >> >
> > >> > On Thu, Mar 16, 2023 at 8:56 AM Chandra S. Rangavajjula (Nokia)
> > >> >  wrote:
> > >> > >
> > >> > > Hi,
> > >> > > I am using glog in my application development. With the latest 
> tag (https://github.com/golang/glog/releases/tag/v1.1.0), there started a 
> new panic error with -vmodule. This issue was not there in older version.
> > >>
> > >> Thanks for the report. The panic stems from the flag package trying to
> > >> call .String on the mentioned glog.vModuleFlag type. I'll fix this
> > >> internally and publish a new version soon.
> > >>
> > >> > >
> > >> > > 
> 
> > >> > > Error:-
> > >> > > 
> 
> > >> > > $./tst --help
> > >> > > usage: example -stderrthreshold=[INFO|WARNING|FATAL] 
> -log_dir=[string]
> > >> > > -alsologtostderr
> > >> > > log to standard error as well as files
> > >> > > -log_backtrace_at value
> > >> > > when logging hits line file:N, emit a stack trace
> > >> > > -log_dir string
> > >> > > If non-empty, write log files in this directory
> > >> > > -log_link string
> > >> > > If non-empty, add symbolic links in this directory to the log 
> files
> > >> > > -logbuflevel int
> > >> > > Buffer log messages logged at this level or lower (-1 means don't 
> buffer; 0 means buffer INFO only; ...). Has limited applicability on 
> non-prod platforms.
> > >> > > -logtostderr
> > >> > > log to standard error instead of files
> > >> > > -stderrthreshold value
> > >> > > logs at or above this threshold go to stderr (default 2)
> > >> > > -v value
> > >> > > log level for V logs
> > >> > > -vmodule value
> > >> > > comma-separated list of pattern=N settings for file-filtered 
> logging
> > >> > >
> > >> > > panic calling String method on zero glog.vModuleFlag for flag 
> vmodule: runtime error: invalid memory address or nil pointer dereference
> > >> > >
> > >> > > 
> 
> > >> > > Example code:-
> > >> > > 
> 
> > >> > > package main
> > >> > >
> > >> > > import (
> > >> > > "github.com/golang/glog"
> > >> > > "os"
> > >> > > "flag"
> > >> > > "fmt"
> > >> > > )
> > >> > >
> > >> > > func usage() {
> > >> > > fmt.Fprintf(os.Stderr, "usage: example 
> -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]\n", )
> > >> > > flag.PrintDefaults()
> > >> > > os.Exit(2)
> > >> > > }
> > >> > >
> > >> > > func init() {
> > >> > > flag.Usage = usage
> > >> > > // NOTE: This next line is key you have to call flag.Parse() for 
> the command line
> > >> > > // options or "flags" that are defined in the glog module to be 
> picked up.
> > >> > > flag.Parse()
> > >> > > }
> > >> > >
> > >> > > func main() {
> > >> > > number_of_lines := 10
> > >> > > for i := 0; i < number_of_lines; i++ {
> > >> > > glog.V(2).Infof("LINE: %d", i)
> > >> > > message := fmt.Sprintf("TEST LINE: %d", i)
> > >> > > glog.Error(message)
> > >> > > }
> > >> > > glog.Flush()
> > >> > > }
> > >> > > 
> 
> > >> > >
> > >> > > Regards,
> > >> > > Chandra R
> > >> > >
> > >> > > --
> > >> > > 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.
> > >> > > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/AS4PR07MB875652B4C33A66DF22D15C5BC3BC9%40AS4PR07MB8756.eurprd07.prod.outlook.com
> .
> > >> >
> > >> > --
> > >> 

Re: [go-nuts] Issue with glog https://github.com/golang/glog/releases/tag/v1.1.0

2023-03-22 Thread 'Chressie Himpel' via golang-nuts
On Mon, Mar 20, 2023 at 6:07 PM Chressie Himpel  wrote:
>
> On Mon, Mar 20, 2023 at 4:44 PM chandra sekhar  
> wrote:
> >
> > Hi,
> > I see that you have already provided a fix for this issue 
> > https://github.com/golang/glog/commit/9c9801e69114b582b12aa7010c75fe2105ae23b3.
> > Any idea when you will make a new tag release with this fix?
>
> I have another fix in the pipeline that i would like to land before
> tagging a new release. It should be a matter of a few days. Thanks for
> your patience.

I just tagged https://github.com/golang/glog/releases/tag/v1.1.1 that
contains the fix.

>
> >
> > Regards,
> > Chandra R.
> >
> > On Thursday, March 16, 2023 at 9:17:20 PM UTC+2 Chressie Himpel wrote:
> >>
> >> On Thu, Mar 16, 2023 at 5:24 PM Ian Lance Taylor  wrote:
> >> >
> >> > [ + jba ]
> >> >
> >> > On Thu, Mar 16, 2023 at 8:56 AM Chandra S. Rangavajjula (Nokia)
> >> >  wrote:
> >> > >
> >> > > Hi,
> >> > > I am using glog in my application development. With the latest tag 
> >> > > (https://github.com/golang/glog/releases/tag/v1.1.0), there started a 
> >> > > new panic error with -vmodule. This issue was not there in older 
> >> > > version.
> >>
> >> Thanks for the report. The panic stems from the flag package trying to
> >> call .String on the mentioned glog.vModuleFlag type. I'll fix this
> >> internally and publish a new version soon.
> >>
> >> > >
> >> > > 
> >> > > Error:-
> >> > > 
> >> > > $./tst --help
> >> > > usage: example -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]
> >> > > -alsologtostderr
> >> > > log to standard error as well as files
> >> > > -log_backtrace_at value
> >> > > when logging hits line file:N, emit a stack trace
> >> > > -log_dir string
> >> > > If non-empty, write log files in this directory
> >> > > -log_link string
> >> > > If non-empty, add symbolic links in this directory to the log files
> >> > > -logbuflevel int
> >> > > Buffer log messages logged at this level or lower (-1 means don't 
> >> > > buffer; 0 means buffer INFO only; ...). Has limited applicability on 
> >> > > non-prod platforms.
> >> > > -logtostderr
> >> > > log to standard error instead of files
> >> > > -stderrthreshold value
> >> > > logs at or above this threshold go to stderr (default 2)
> >> > > -v value
> >> > > log level for V logs
> >> > > -vmodule value
> >> > > comma-separated list of pattern=N settings for file-filtered logging
> >> > >
> >> > > panic calling String method on zero glog.vModuleFlag for flag vmodule: 
> >> > > runtime error: invalid memory address or nil pointer dereference
> >> > >
> >> > > 
> >> > > Example code:-
> >> > > 
> >> > > package main
> >> > >
> >> > > import (
> >> > > "github.com/golang/glog"
> >> > > "os"
> >> > > "flag"
> >> > > "fmt"
> >> > > )
> >> > >
> >> > > func usage() {
> >> > > fmt.Fprintf(os.Stderr, "usage: example 
> >> > > -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]\n", )
> >> > > flag.PrintDefaults()
> >> > > os.Exit(2)
> >> > > }
> >> > >
> >> > > func init() {
> >> > > flag.Usage = usage
> >> > > // NOTE: This next line is key you have to call flag.Parse() for the 
> >> > > command line
> >> > > // options or "flags" that are defined in the glog module to be picked 
> >> > > up.
> >> > > flag.Parse()
> >> > > }
> >> > >
> >> > > func main() {
> >> > > number_of_lines := 10
> >> > > for i := 0; i < number_of_lines; i++ {
> >> > > glog.V(2).Infof("LINE: %d", i)
> >> > > message := fmt.Sprintf("TEST LINE: %d", i)
> >> > > glog.Error(message)
> >> > > }
> >> > > glog.Flush()
> >> > > }
> >> > > 
> >> > >
> >> > > Regards,
> >> > > Chandra R
> >> > >
> >> > > --
> >> > > 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.
> >> > > To view this discussion on the web visit 
> >> > > https://groups.google.com/d/msgid/golang-nuts/AS4PR07MB875652B4C33A66DF22D15C5BC3BC9%40AS4PR07MB8756.eurprd07.prod.outlook.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...@googlegroups.com.
> >> > To view this discussion on the web visit 
> >> > 

Re: [go-nuts] Issue with glog https://github.com/golang/glog/releases/tag/v1.1.0

2023-03-20 Thread 'Chressie Himpel' via golang-nuts
On Mon, Mar 20, 2023 at 4:44 PM chandra sekhar  wrote:
>
> Hi,
> I see that you have already provided a fix for this issue 
> https://github.com/golang/glog/commit/9c9801e69114b582b12aa7010c75fe2105ae23b3.
> Any idea when you will make a new tag release with this fix?

I have another fix in the pipeline that i would like to land before
tagging a new release. It should be a matter of a few days. Thanks for
your patience.

>
> Regards,
> Chandra R.
>
> On Thursday, March 16, 2023 at 9:17:20 PM UTC+2 Chressie Himpel wrote:
>>
>> On Thu, Mar 16, 2023 at 5:24 PM Ian Lance Taylor  wrote:
>> >
>> > [ + jba ]
>> >
>> > On Thu, Mar 16, 2023 at 8:56 AM Chandra S. Rangavajjula (Nokia)
>> >  wrote:
>> > >
>> > > Hi,
>> > > I am using glog in my application development. With the latest tag 
>> > > (https://github.com/golang/glog/releases/tag/v1.1.0), there started a 
>> > > new panic error with -vmodule. This issue was not there in older version.
>>
>> Thanks for the report. The panic stems from the flag package trying to
>> call .String on the mentioned glog.vModuleFlag type. I'll fix this
>> internally and publish a new version soon.
>>
>> > >
>> > > 
>> > > Error:-
>> > > 
>> > > $./tst --help
>> > > usage: example -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]
>> > > -alsologtostderr
>> > > log to standard error as well as files
>> > > -log_backtrace_at value
>> > > when logging hits line file:N, emit a stack trace
>> > > -log_dir string
>> > > If non-empty, write log files in this directory
>> > > -log_link string
>> > > If non-empty, add symbolic links in this directory to the log files
>> > > -logbuflevel int
>> > > Buffer log messages logged at this level or lower (-1 means don't 
>> > > buffer; 0 means buffer INFO only; ...). Has limited applicability on 
>> > > non-prod platforms.
>> > > -logtostderr
>> > > log to standard error instead of files
>> > > -stderrthreshold value
>> > > logs at or above this threshold go to stderr (default 2)
>> > > -v value
>> > > log level for V logs
>> > > -vmodule value
>> > > comma-separated list of pattern=N settings for file-filtered logging
>> > >
>> > > panic calling String method on zero glog.vModuleFlag for flag vmodule: 
>> > > runtime error: invalid memory address or nil pointer dereference
>> > >
>> > > 
>> > > Example code:-
>> > > 
>> > > package main
>> > >
>> > > import (
>> > > "github.com/golang/glog"
>> > > "os"
>> > > "flag"
>> > > "fmt"
>> > > )
>> > >
>> > > func usage() {
>> > > fmt.Fprintf(os.Stderr, "usage: example 
>> > > -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]\n", )
>> > > flag.PrintDefaults()
>> > > os.Exit(2)
>> > > }
>> > >
>> > > func init() {
>> > > flag.Usage = usage
>> > > // NOTE: This next line is key you have to call flag.Parse() for the 
>> > > command line
>> > > // options or "flags" that are defined in the glog module to be picked 
>> > > up.
>> > > flag.Parse()
>> > > }
>> > >
>> > > func main() {
>> > > number_of_lines := 10
>> > > for i := 0; i < number_of_lines; i++ {
>> > > glog.V(2).Infof("LINE: %d", i)
>> > > message := fmt.Sprintf("TEST LINE: %d", i)
>> > > glog.Error(message)
>> > > }
>> > > glog.Flush()
>> > > }
>> > > 
>> > >
>> > > Regards,
>> > > Chandra R
>> > >
>> > > --
>> > > 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.
>> > > To view this discussion on the web visit 
>> > > https://groups.google.com/d/msgid/golang-nuts/AS4PR07MB875652B4C33A66DF22D15C5BC3BC9%40AS4PR07MB8756.eurprd07.prod.outlook.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...@googlegroups.com.
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXXuFg24BCDAtSRLd2XjSqVJOHtMfbdqMH-EryF0mK7iA%40mail.gmail.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.
> To view this discussion on the web visit 
> 

Re: [go-nuts] Issue with glog https://github.com/golang/glog/releases/tag/v1.1.0

2023-03-20 Thread chandra sekhar
Hi,
I see that you have already provided a fix for this issue 
https://github.com/golang/glog/commit/9c9801e69114b582b12aa7010c75fe2105ae23b3
.
Any idea when you will make a new tag release with this fix?

Regards,
Chandra R.

On Thursday, March 16, 2023 at 9:17:20 PM UTC+2 Chressie Himpel wrote:

> On Thu, Mar 16, 2023 at 5:24 PM Ian Lance Taylor  wrote:
> >
> > [ + jba ]
> >
> > On Thu, Mar 16, 2023 at 8:56 AM Chandra S. Rangavajjula (Nokia)
> >  wrote:
> > >
> > > Hi,
> > > I am using glog in my application development. With the latest tag (
> https://github.com/golang/glog/releases/tag/v1.1.0), there started a new 
> panic error with -vmodule. This issue was not there in older version.
>
> Thanks for the report. The panic stems from the flag package trying to
> call .String on the mentioned glog.vModuleFlag type. I'll fix this
> internally and publish a new version soon.
>
> > >
> > > 
> 
> > > Error:-
> > > 
> 
> > > $./tst --help
> > > usage: example -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]
> > > -alsologtostderr
> > > log to standard error as well as files
> > > -log_backtrace_at value
> > > when logging hits line file:N, emit a stack trace
> > > -log_dir string
> > > If non-empty, write log files in this directory
> > > -log_link string
> > > If non-empty, add symbolic links in this directory to the log files
> > > -logbuflevel int
> > > Buffer log messages logged at this level or lower (-1 means don't 
> buffer; 0 means buffer INFO only; ...). Has limited applicability on 
> non-prod platforms.
> > > -logtostderr
> > > log to standard error instead of files
> > > -stderrthreshold value
> > > logs at or above this threshold go to stderr (default 2)
> > > -v value
> > > log level for V logs
> > > -vmodule value
> > > comma-separated list of pattern=N settings for file-filtered logging
> > >
> > > panic calling String method on zero glog.vModuleFlag for flag vmodule: 
> runtime error: invalid memory address or nil pointer dereference
> > >
> > > 
> 
> > > Example code:-
> > > 
> 
> > > package main
> > >
> > > import (
> > > "github.com/golang/glog"
> > > "os"
> > > "flag"
> > > "fmt"
> > > )
> > >
> > > func usage() {
> > > fmt.Fprintf(os.Stderr, "usage: example 
> -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]\n", )
> > > flag.PrintDefaults()
> > > os.Exit(2)
> > > }
> > >
> > > func init() {
> > > flag.Usage = usage
> > > // NOTE: This next line is key you have to call flag.Parse() for the 
> command line
> > > // options or "flags" that are defined in the glog module to be picked 
> up.
> > > flag.Parse()
> > > }
> > >
> > > func main() {
> > > number_of_lines := 10
> > > for i := 0; i < number_of_lines; i++ {
> > > glog.V(2).Infof("LINE: %d", i)
> > > message := fmt.Sprintf("TEST LINE: %d", i)
> > > glog.Error(message)
> > > }
> > > glog.Flush()
> > > }
> > > 
> 
> > >
> > > Regards,
> > > Chandra R
> > >
> > > --
> > > 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.
> > > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/AS4PR07MB875652B4C33A66DF22D15C5BC3BC9%40AS4PR07MB8756.eurprd07.prod.outlook.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...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXXuFg24BCDAtSRLd2XjSqVJOHtMfbdqMH-EryF0mK7iA%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e0353b10-21c9-4540-a107-8eea8104e6f7n%40googlegroups.com.


Re: [go-nuts] Issue with glog https://github.com/golang/glog/releases/tag/v1.1.0

2023-03-16 Thread 'Chressie Himpel' via golang-nuts
On Thu, Mar 16, 2023 at 5:24 PM Ian Lance Taylor  wrote:
>
> [ + jba ]
>
> On Thu, Mar 16, 2023 at 8:56 AM Chandra S. Rangavajjula (Nokia)
>  wrote:
> >
> > Hi,
> > I am using glog in my application development. With the latest tag 
> > (https://github.com/golang/glog/releases/tag/v1.1.0), there started a new 
> > panic error with -vmodule. This issue was not there in older version.

Thanks for the report. The panic stems from the flag package trying to
call .String on the mentioned glog.vModuleFlag type. I'll fix this
internally and publish a new version soon.

> >
> > 
> > Error:-
> > 
> > $./tst --help
> > usage: example -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]
> >   -alsologtostderr
> > log to standard error as well as files
> >   -log_backtrace_at value
> > when logging hits line file:N, emit a stack trace
> >   -log_dir string
> > If non-empty, write log files in this directory
> >   -log_link string
> > If non-empty, add symbolic links in this directory to the log files
> >   -logbuflevel int
> > Buffer log messages logged at this level or lower (-1 means don't 
> > buffer; 0 means buffer INFO only; ...). Has limited applicability on 
> > non-prod platforms.
> >   -logtostderr
> > log to standard error instead of files
> >   -stderrthreshold value
> > logs at or above this threshold go to stderr (default 2)
> >   -v value
> > log level for V logs
> >   -vmodule value
> > comma-separated list of pattern=N settings for file-filtered logging
> >
> > panic calling String method on zero glog.vModuleFlag for flag vmodule: 
> > runtime error: invalid memory address or nil pointer dereference
> >
> > 
> > Example code:-
> > 
> > package main
> >
> > import (
> > "github.com/golang/glog"
> > "os"
> > "flag"
> > "fmt"
> > )
> >
> > func usage() {
> > fmt.Fprintf(os.Stderr, "usage: example 
> > -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]\n", )
> > flag.PrintDefaults()
> > os.Exit(2)
> > }
> >
> > func init() {
> > flag.Usage = usage
> > // NOTE: This next line is key you have to call flag.Parse() for the 
> > command line
> > // options or "flags" that are defined in the glog module to be picked up.
> > flag.Parse()
> > }
> >
> > func main() {
> > number_of_lines := 10
> > for i := 0; i < number_of_lines; i++ {
> > glog.V(2).Infof("LINE: %d", i)
> > message := fmt.Sprintf("TEST LINE: %d", i)
> > glog.Error(message)
> > }
> > glog.Flush()
> > }
> > 
> >
> > Regards,
> > Chandra R
> >
> > --
> > 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/AS4PR07MB875652B4C33A66DF22D15C5BC3BC9%40AS4PR07MB8756.eurprd07.prod.outlook.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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXXuFg24BCDAtSRLd2XjSqVJOHtMfbdqMH-EryF0mK7iA%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAPgVe6MpdRfbDx%3Dp0zt2AtJb_74rs3ZH0Ve_i4SdTowmg8aUqQ%40mail.gmail.com.


Re: [go-nuts] Issue with glog https://github.com/golang/glog/releases/tag/v1.1.0

2023-03-16 Thread Ian Lance Taylor
[ + jba ]

On Thu, Mar 16, 2023 at 8:56 AM Chandra S. Rangavajjula (Nokia)
 wrote:
>
> Hi,
> I am using glog in my application development. With the latest tag 
> (https://github.com/golang/glog/releases/tag/v1.1.0), there started a new 
> panic error with -vmodule. This issue was not there in older version.
>
> 
> Error:-
> 
> $./tst --help
> usage: example -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]
>   -alsologtostderr
>   log to standard error as well as files
>   -log_backtrace_at value
>   when logging hits line file:N, emit a stack trace
>   -log_dir string
>   If non-empty, write log files in this directory
>   -log_link string
>   If non-empty, add symbolic links in this directory to the log files
>   -logbuflevel int
>   Buffer log messages logged at this level or lower (-1 means don't 
> buffer; 0 means buffer INFO only; ...). Has limited applicability on non-prod 
> platforms.
>   -logtostderr
>   log to standard error instead of files
>   -stderrthreshold value
>   logs at or above this threshold go to stderr (default 2)
>   -v value
>   log level for V logs
>   -vmodule value
>   comma-separated list of pattern=N settings for file-filtered logging
>
> panic calling String method on zero glog.vModuleFlag for flag vmodule: 
> runtime error: invalid memory address or nil pointer dereference
>
> 
> Example code:-
> 
> package main
>
> import (
>   "github.com/golang/glog"
>   "os"
>   "flag"
>   "fmt"
> )
>
> func usage() {
>   fmt.Fprintf(os.Stderr, "usage: example 
> -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]\n", )
>   flag.PrintDefaults()
>   os.Exit(2)
> }
>
> func init() {
>   flag.Usage = usage
>   // NOTE: This next line is key you have to call flag.Parse() for the 
> command line
>   // options or "flags" that are defined in the glog module to be picked 
> up.
>   flag.Parse()
> }
>
> func main() {
>   number_of_lines := 10
>   for i := 0; i < number_of_lines; i++ {
> glog.V(2).Infof("LINE: %d", i)
> message := fmt.Sprintf("TEST LINE: %d", i)
> glog.Error(message)
>   }
>   glog.Flush()
> }
> 
>
> Regards,
> Chandra R
>
> --
> 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/AS4PR07MB875652B4C33A66DF22D15C5BC3BC9%40AS4PR07MB8756.eurprd07.prod.outlook.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXXuFg24BCDAtSRLd2XjSqVJOHtMfbdqMH-EryF0mK7iA%40mail.gmail.com.


[go-nuts] Issue with glog https://github.com/golang/glog/releases/tag/v1.1.0

2023-03-16 Thread Chandra S. Rangavajjula (Nokia)
Hi,
I am using glog in my application development. With the latest tag 
(https://github.com/golang/glog/releases/tag/v1.1.0), there started a new panic 
error with -vmodule. This issue was not there in older version.


Error:-

$./tst --help
usage: example -stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]
  -alsologtostderr
  log to standard error as well as files
  -log_backtrace_at value
  when logging hits line file:N, emit a stack trace
  -log_dir string
  If non-empty, write log files in this directory
  -log_link string
  If non-empty, add symbolic links in this directory to the log files
  -logbuflevel int
  Buffer log messages logged at this level or lower (-1 means don't buffer; 
0 means buffer INFO only; ...). Has limited applicability on non-prod platforms.
  -logtostderr
  log to standard error instead of files
  -stderrthreshold value
  logs at or above this threshold go to stderr (default 2)
  -v value
  log level for V logs
  -vmodule value
  comma-separated list of pattern=N settings for file-filtered logging

panic calling String method on zero glog.vModuleFlag for flag vmodule: runtime 
error: invalid memory address or nil pointer dereference


Example code:-

package main

import (
  "github.com/golang/glog"
  "os"
  "flag"
  "fmt"
)

func usage() {
  fmt.Fprintf(os.Stderr, "usage: example 
-stderrthreshold=[INFO|WARNING|FATAL] -log_dir=[string]\n", )
  flag.PrintDefaults()
  os.Exit(2)
}

func init() {
  flag.Usage = usage
  // NOTE: This next line is key you have to call flag.Parse() for the 
command line
  // options or "flags" that are defined in the glog module to be picked up.
  flag.Parse()
}

func main() {
  number_of_lines := 10
  for i := 0; i < number_of_lines; i++ {
glog.V(2).Infof("LINE: %d", i)
message := fmt.Sprintf("TEST LINE: %d", i)
glog.Error(message)
  }
  glog.Flush()
}


Regards,
Chandra R

-- 
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/AS4PR07MB875652B4C33A66DF22D15C5BC3BC9%40AS4PR07MB8756.eurprd07.prod.outlook.com.


Re: [go-nuts] Issue implementing interface method that returns another interface

2023-03-02 Thread Rick Schubert
Thank you for the help @Axel Wagner

On Tuesday, 28 February 2023 at 18:20:54 UTC Axel Wagner wrote:

> You are running into this: https://go.dev/doc/faq#covariant_types
>
> > How could I do that?
>
> You probably have to write a wrapper. Or change the concrete type to 
> return an interface. Or test using the concrete type, instead of using 
> mocks.
>
> On Tue, Feb 28, 2023 at 6:08 PM Rick Schubert  
> wrote:
>
>> I am having a question about how to implement interfaces correctly in Go 
>> when it comes to third-party packages that use chained methods. I have 
>> compiled an example project below for you so that you can understand the 
>> problem.
>>
>>
>> package main
>>
>> import (
>> myAPI "github.com/hashicorp/vault/api"
>> )
>>
>> var myClient *myAPI.Client
>>
>> type MyProvider interface {
>> GetClient() MyAPIClient
>> }
>>
>> type MyAPIClient interface {
>> // I want to do this but it does not work
>> Logical() MyAPILogical
>> // This works though
>> // Logical() *myAPI.Logical
>> }
>>
>> type MyAPILogical interface {
>> Write(path string, data map[string]interface{}) (*myAPI.Secret, error)
>> }
>>
>> type Provider struct {}
>>
>> func PublicFunctionIWantToTest(provider MyProvider) {
>> client := provider.GetClient()
>> // We normally do something here with the 'client' variable, but important
>> // is that we forward it later on
>> privateFunctionThatIsUsedInTheTest(client)
>> }
>>
>> func privateFunctionThatIsUsedInTheTest(client MyAPIClient) 
>> (*myAPI.Secret, error) {
>> return client.Logical().Write(
>> "/here/goes/some/path",
>> map[string]interface{}{
>> "key": "value",
>> },
>> )
>> }
>>
>> func NewProvider() MyProvider {
>> return Provider{}
>> }
>>
>> func (p Provider) GetClient() MyAPIClient {
>> return myClient
>> }
>>
>> // Empty function just so that this example can be built
>> func main() {}
>>
>>
>> As you can see, the package has a chained method Logical().Write() . 
>> Since I want to create tests for PublicFunctionIWantToTest, I want to 
>> pass down all the functionality as interface so that I can use 
>> https://vektra.github.io/mockery/ to create mocks for it.
>>
>> Unfortunately, I am hitting an issue with my MyAPIClient and the 
>> MyAPILogical interface. Since I can see in the package's documentation (
>> https://pkg.go.dev/github.com/hashicorp/vault/a...@v1.8.1#Logical.Write 
>> ) 
>> that the Logical() method returns a Logical instance, I want to make it 
>> so that interface method returns the other interface MyAPILogical (line 
>> 15). This does not work though, there is an error on line 47 in the 
>> GetClient() method saying that I would not implement the interface 
>> correctly. How could I do that?
>>
>> cannot use myClient (variable of type *api.Client) as MyAPIClient value 
>> in return statement: *api.Client does not implement MyAPIClient (wrong type 
>> for method Logical)
>> have Logical() *api.Logical
>> want Logical() MyAPILogicalcompilerInvalidIfaceAssign
>>
>> Thank you kindly
>>
>> -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/1bf2aef5-14af-4565-8f4c-538a1edeb380n%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6ecb374a-e204-4069-98c8-ed2195f10945n%40googlegroups.com.


Re: [go-nuts] Issue implementing interface method that returns another interface

2023-02-28 Thread 'Axel Wagner' via golang-nuts
You are running into this: https://go.dev/doc/faq#covariant_types

> How could I do that?

You probably have to write a wrapper. Or change the concrete type to return
an interface. Or test using the concrete type, instead of using mocks.

On Tue, Feb 28, 2023 at 6:08 PM Rick Schubert 
wrote:

> I am having a question about how to implement interfaces correctly in Go
> when it comes to third-party packages that use chained methods. I have
> compiled an example project below for you so that you can understand the
> problem.
>
>
> package main
>
> import (
> myAPI "github.com/hashicorp/vault/api"
> )
>
> var myClient *myAPI.Client
>
> type MyProvider interface {
> GetClient() MyAPIClient
> }
>
> type MyAPIClient interface {
> // I want to do this but it does not work
> Logical() MyAPILogical
> // This works though
> // Logical() *myAPI.Logical
> }
>
> type MyAPILogical interface {
> Write(path string, data map[string]interface{}) (*myAPI.Secret, error)
> }
>
> type Provider struct {}
>
> func PublicFunctionIWantToTest(provider MyProvider) {
> client := provider.GetClient()
> // We normally do something here with the 'client' variable, but important
> // is that we forward it later on
> privateFunctionThatIsUsedInTheTest(client)
> }
>
> func privateFunctionThatIsUsedInTheTest(client MyAPIClient)
> (*myAPI.Secret, error) {
> return client.Logical().Write(
> "/here/goes/some/path",
> map[string]interface{}{
> "key": "value",
> },
> )
> }
>
> func NewProvider() MyProvider {
> return Provider{}
> }
>
> func (p Provider) GetClient() MyAPIClient {
> return myClient
> }
>
> // Empty function just so that this example can be built
> func main() {}
>
>
> As you can see, the package has a chained method Logical().Write() .
> Since I want to create tests for PublicFunctionIWantToTest, I want to
> pass down all the functionality as interface so that I can use
> https://vektra.github.io/mockery/ to create mocks for it.
>
> Unfortunately, I am hitting an issue with my MyAPIClient and the
> MyAPILogical interface. Since I can see in the package's documentation (
> https://pkg.go.dev/github.com/hashicorp/vault/api@v1.8.1#Logical.Write)
> that the Logical() method returns a Logical instance, I want to make it
> so that interface method returns the other interface MyAPILogical (line
> 15). This does not work though, there is an error on line 47 in the
> GetClient() method saying that I would not implement the interface
> correctly. How could I do that?
>
> cannot use myClient (variable of type *api.Client) as MyAPIClient value in
> return statement: *api.Client does not implement MyAPIClient (wrong type
> for method Logical)
> have Logical() *api.Logical
> want Logical() MyAPILogicalcompilerInvalidIfaceAssign
>
> Thank you kindly
>
> --
> 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/1bf2aef5-14af-4565-8f4c-538a1edeb380n%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfGwN3GkWvMhBUf0MeNpBtR%2B%2B6zZHxYMF3WKxccdasQbsg%40mail.gmail.com.


[go-nuts] Issue implementing interface method that returns another interface

2023-02-28 Thread Rick Schubert
I am having a question about how to implement interfaces correctly in Go 
when it comes to third-party packages that use chained methods. I have 
compiled an example project below for you so that you can understand the 
problem.


package main

import (
myAPI "github.com/hashicorp/vault/api"
)

var myClient *myAPI.Client

type MyProvider interface {
GetClient() MyAPIClient
}

type MyAPIClient interface {
// I want to do this but it does not work
Logical() MyAPILogical
// This works though
// Logical() *myAPI.Logical
}

type MyAPILogical interface {
Write(path string, data map[string]interface{}) (*myAPI.Secret, error)
}

type Provider struct {}

func PublicFunctionIWantToTest(provider MyProvider) {
client := provider.GetClient()
// We normally do something here with the 'client' variable, but important
// is that we forward it later on
privateFunctionThatIsUsedInTheTest(client)
}

func privateFunctionThatIsUsedInTheTest(client MyAPIClient) (*myAPI.Secret, 
error) {
return client.Logical().Write(
"/here/goes/some/path",
map[string]interface{}{
"key": "value",
},
)
}

func NewProvider() MyProvider {
return Provider{}
}

func (p Provider) GetClient() MyAPIClient {
return myClient
}

// Empty function just so that this example can be built
func main() {}


As you can see, the package has a chained method Logical().Write() . Since 
I want to create tests for PublicFunctionIWantToTest, I want to pass down 
all the functionality as interface so that I can use 
https://vektra.github.io/mockery/ to create mocks for it.

Unfortunately, I am hitting an issue with my MyAPIClient and the 
MyAPILogical interface. Since I can see in the package's documentation 
(https://pkg.go.dev/github.com/hashicorp/vault/api@v1.8.1#Logical.Write) 
that the Logical() method returns a Logical instance, I want to make it so 
that interface method returns the other interface MyAPILogical (line 15). 
This does not work though, there is an error on line 47 in the GetClient() 
method saying that I would not implement the interface correctly. How could 
I do that?

cannot use myClient (variable of type *api.Client) as MyAPIClient value in 
return statement: *api.Client does not implement MyAPIClient (wrong type 
for method Logical)
have Logical() *api.Logical
want Logical() MyAPILogicalcompilerInvalidIfaceAssign

Thank you kindly

-- 
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/1bf2aef5-14af-4565-8f4c-538a1edeb380n%40googlegroups.com.


[go-nuts] Issue with regular expression processing

2022-12-05 Thread sbezverk
Hello,

 

I came across a strange behavior in regular expression processing, please see 
the following simple code which is supposed to match the second line of data 
variable.

 

https://go.dev/play/p/QPrNRuhCv8r

 

The matching data starts at the beginning of the 3rd line so I expect the 
pattern `^` + l + `\s+([0-9]+)\s+` would result in a match, but it does not. If 
I remove `^` from the regular expression, then the match is found. Running 
`grep -E` with regular expression which includes `^` also finds the expected 
match.

 

Appreciate some feedback. Is it a bug or I do something incorrectly?

 

Thank you

Serguei 

-- 
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/1DF73419-C0C8-48CD-ACE5-8745927C70F9%40gmail.com.


Re: [go-nuts] Issue with go-git API

2022-10-10 Thread Martin Schnabel

Hi PK,

most of the time examples are single file programs to be used with go 
run. if you are inside the module root that covers all the dependencies 
(or decend into the relevant example folder) you can use `go run 
main.go` to run the example file.


I just tired it with the same repository and it works as expected and 
described.


have fun!

On 10/10/22 07:35, PK wrote:
I am trying to use this git api(*https://github.com/go-git/go-git*), but 
before that I tried to run the provided example (i.e. cloning the repo 
by golang). So I run the program

*https://github.com/go-git/go-git/blob/master/_examples/clone/main.go*

So when I run this program I used to get this error:
sample.go:7:2: no required module provides package 
github.com/go-git/go-git/v5: go.mod file not found in current directory 
or any parent directory; see 'go help modules'


sample.go:8:2: no required module provides package 
github.com/go-git/go-git/v5/_examples: go.mod file not found in current 
directory or any parent directory; see 'go help modules'


*Please help me, how I can execute this?*

I am using the following:
Go version: go version go1.18.1 linux/amd64
Platform:  Ubuntu 22.04.1 LTS

--
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/353c43c7-99bc-4e85-bf94-a5daff749640n%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/037ea98b-6cab-66cf-cb31-e67a10f603ac%40mb0.org.


[go-nuts] Issue with go-git API

2022-10-09 Thread PK
I am trying to use this git api(*https://github.com/go-git/go-git*), but 
before that I tried to run the provided example (i.e. cloning the repo by 
golang). So I run the program 
*https://github.com/go-git/go-git/blob/master/_examples/clone/main.go*

So when I run this program I used to get this error:
sample.go:7:2: no required module provides package 
github.com/go-git/go-git/v5: go.mod file not found in current directory or 
any parent directory; see 'go help modules'

sample.go:8:2: no required module provides package 
github.com/go-git/go-git/v5/_examples: go.mod file not found in current 
directory or any parent directory; see 'go help modules'

*Please help me, how I can execute this?*

I am using the following:
Go version: go version go1.18.1 linux/amd64
Platform:  Ubuntu 22.04.1 LTS

-- 
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/353c43c7-99bc-4e85-bf94-a5daff749640n%40googlegroups.com.


[go-nuts] Issue syscall.Proc.Call win32 function ERROR_MORE_DATA

2022-06-17 Thread Nicolas Schwartz
Hello,

I am trying to use cfapi.h/cldapi.dll from golang.
I am able to call some function however for CfConnectSyncRoot I always get 
ERROR_MORE_DATA on the third argument of syscall.Proc.Call().

Cf my code:
func CfConnectSyncRoot(syncRootPath string, callbackTable 
CfCallbackRegistrations, callbackContext []byte, connectFlags 
CfConnectFlag) (*CfConnectionKey, error) {
wstrSyncRootPath, err := syscall.UTF16PtrFromString(syncRootPath)
if err != nil {
return nil, err
}

ct := callbackTable.DllEncode()
cbCtx := uintptr(0)
if len(callbackContext) > 0 {
cbCtx = uintptr(unsafe.Pointer([0]))
}

cfKey := CfConnectionKey(0)

ret, _, errno := 
inst.hCfConnectSyncRoot.Call(uintptr(unsafe.Pointer(wstrSyncRootPath)), 
uintptr(unsafe.Pointer([0])), cbCtx, uintptr(connectFlags), uintptr
(unsafe.Pointer()))
fmt.Println(errno)
if ret != S_OK {
return nil, fmt.Errorf("Error CfConnectSyncRoot result %#x", ret)
}
return , nil
}


fmt.Println(errno) is throwing the error code.
Do you have any idea ?

Thanks in advance,

Nicolas

-- 
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/a9948362-06d4-4581-b04f-c5940cd038edn%40googlegroups.com.


[go-nuts] Issue: x/net/html Node and attributes constructor function

2021-07-12 Thread atd...@gmail.com
Just wondering if people would feel it worthy to have COnstructor functions 
to create html.Nodes, attributes, and set attributes on html.Nodes.

I'm writing some kind of metaframework targeting the web and mobile (think 
flutter for Go) and basically finished the web target via wasm.

But I'd like to convert the app tree into an html node tree for static 
generation of pages (think isomorphic app server or whatever the 
terminology frontend dev use nowadays)

After having looked at different solutions, x/net/html seems simple enough 
albeit a bit lacking.

Maybe it is by design for people to build upon it though.

So, do I prepare PRs or just build on it for myself?

-- 
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/08d87d51-2140-4461-b4d5-b4d6603dc1b1n%40googlegroups.com.


[go-nuts] Issue with go and mongodb

2020-04-08 Thread Ali Hassan
I want build connection with mongodb and go1.14 linux/amd
 But it throw this 
 error parsing uri : lookup abc-hwykp.mongonet 
on 127.0.0.53:53: cannot unmarshal DNS message 

*Mongoclient code :*

[image: Capture.JPG]

[image: Capture.JPG]

Please help me 

-- 
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/09bb1095-4c6d-4f4b-bb41-c5609cb3f79e%40googlegroups.com.


Re: [go-nuts] Issue with handler

2020-03-20 Thread Kurtis Rader
On Fri, Mar 20, 2020 at 11:50 AM Ali Hassan 
wrote:

> I have two html files
>index and login
>  Index return status = 200
>  login return status = 400
>
> Code snipnet
>

I didn't see any code. All I saw were two pictures that didn't make any
sense :-)

In other words, please post plain text or a link to play.golang.org.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD-ry7d7ZQ7hw0Tn82PgjmfOJq0E%3DG0abaP9AQiRTCwYYw%40mail.gmail.com.


Re: [go-nuts] Issue with handler

2020-03-20 Thread robert engels
You have no login.html file...

> On Mar 20, 2020, at 1:50 PM, Ali Hassan  wrote:
> 
> I have two html files 
>index and login 
>  Index return status = 200
>  login return status = 400
> 
> Code snipnet
>  
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 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/134f806f-4b20-498e-8a2b-84cab511760d%40googlegroups.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2A6E5C16-F87B-451E-B9E9-54F93A713666%40ix.netcom.com.


[go-nuts] Issue with handler

2020-03-20 Thread Ali Hassan
I have two html files 
   index and login 
 Index return status = 200
 login return status = 400

Code snipnet
 

[image: err2.JPG]

[image: error0.JPG]


-- 
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/134f806f-4b20-498e-8a2b-84cab511760d%40googlegroups.com.


Re: [go-nuts] issue with past-the-end pointer

2020-03-18 Thread Vincent Blanchon
Thank you Ian!


Le mercredi 18 mars 2020 23:20:15 UTC+4, Ian Lance Taylor a écrit :
>
> On Wed, Mar 18, 2020 at 9:33 AM Vincent Blanchon 
> > wrote: 
> > 
> > In this proposal 
> https://github.com/golang/proposal/blob/master/design/24543-non-cooperative-preemption.md,
>  
> it is mentioned past-the-end pointer and the fact it should be avoided. My 
> assumption is that it could lead to a bad memory tracking/cleaning since 
> the write barriers keep track of the change in the pointers. Is that 
> correct? 
>
> Pretty much, yes.  A past-the-end pointer looks like a pointer to the 
> next object, and the write barrier can't tell the difference. 
>
> 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/ed6c6b51-0c19-4ccc-847f-48d629570016%40googlegroups.com.


Re: [go-nuts] issue with past-the-end pointer

2020-03-18 Thread Ian Lance Taylor
On Wed, Mar 18, 2020 at 9:33 AM Vincent Blanchon
 wrote:
>
> In this proposal 
> https://github.com/golang/proposal/blob/master/design/24543-non-cooperative-preemption.md,
>  it is mentioned past-the-end pointer and the fact it should be avoided. My 
> assumption is that it could lead to a bad memory tracking/cleaning since the 
> write barriers keep track of the change in the pointers. Is that correct?

Pretty much, yes.  A past-the-end pointer looks like a pointer to the
next object, and the write barrier can't tell the difference.

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/CAOyqgcVsG9Bmr%3DrMAvs8MNdaxorz9KH-i3X-CtaLQNLSjTTnTA%40mail.gmail.com.


[go-nuts] issue with past-the-end pointer

2020-03-18 Thread Vincent Blanchon
Hi all,

In this 
proposal 
https://github.com/golang/proposal/blob/master/design/24543-non-cooperative-preemption.md,
 
it is mentioned past-the-end pointer and the fact it should be avoided. My 
assumption is that it could lead to a bad memory tracking/cleaning since 
the write barriers keep track of the change in the pointers. Is that 
correct?

Thank you

-- 
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/123409ca-4742-4def-9643-2f23d00bab61%40googlegroups.com.


[go-nuts] issue with yaml processing

2019-12-25 Thread R Srinivasan
I have the following fragment in an input yaml file:

contents: [
 '../etst1/date1from1' , 'var/lib/to1' ,
'from2' , 'to2'
  ]

My go struct for the above looks like:

type Config struct {
 Contents []string `yaml:"contents"`
}

I use the package gopkg.in/yaml.v3

when I unmarshal and immediately reverse Marshal and write it to a file, it 
is represented in a different syntax as in:

contents:
  - - ../test/date1from1
- /var/lib/to1
  - - from2
- to2

I suspect these are equivalent but 

is there a way I can get a reproduction of the input yaml. 

If it is not obvious, this is my first exploration of yaml. Pointers 
appreciated.

Srini

-- 
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/2bf5edf6-e055-44a4-aba5-4e8e0eedda01%40googlegroups.com.


[go-nuts] Issue

2019-09-18 Thread Ali Hassan


[image: error.gif]
I was working on a project (name of project is not allow), however in my 
project i want to show 3d model or my website. My website written in go. 
Aframe i'm using. When my website load 3d model it's show warning and my 
model is not visible on my website. Please help me
  

[image: ERROR.JPG] 

-- 
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/48efac8a-0112-4006-9030-8b1f49b2a0f4%40googlegroups.com.


Re: [go-nuts] Issue using json with array

2019-02-19 Thread Juan Mamani
Thanks Tomás! now  reading info about Marshal

El sábado, 2 de febrero de 2019, 20:24:36 (UTC-3), Tomás González Dowling 
escribió:
>
> Not sure if that was a question, Juan. But you can use Marshal method in 
> the encoding/json package to avoid using make. There are some examples in 
> the official docs: https://golang.org/pkg/encoding/json/#example_Marshal
>
> Hope that it helps :)
>
> El mié., 19 dic. 2018 a las 9:44, Juan Mamani ( >) escribió:
>
>> Thanks a lot for your reply!!  You are right it's working.
>>
>> But, it could be possible to avoid calling "make"...
>>
>> El mié., 19 de dic. de 2018 a la(s) 08:14, Ozone Kawakami (
>> kawakam...@gmail.com ) escribió:
>>
>>> Your code `make(pos, 1)` seems to be typo.
>>> The fixed version works well.
>>> https://play.golang.org/p/gnLe_Xi2-nb
>>>
>>> 2018年12月19日(水) 10:40 Juan Mamani >:
>>>
 I'm not an expert but I do my best.

 Original  json format required:
 { "pos": [{ "lp" : "WISE-12", "lat": "-33,43565400", "lon" : 
 "-70,60552700", "speed" : "102" }] 
 } 

 Json autogenerated from: https://mholt.github.io/json-to-go/ (lazy 
 style but it works. Even more when my boss is surrounding like a shark! 
 jajaa)

 type AutoGenerated struct { Pos []struct { Lp string 
 `json:"license_plate"` Lat string `json:"lat"` Lon string `json:"lon"` 
 Speed string `json:"speed"` } `json:"pos"` }

 So I tried more fancy style but it doesn´t work:(

 type track struct{ Lp string `json:"license_plate"` Lat string 
 `json:"lat"` Lon string `json:"lon"`
 Speed string `json:"speed"`
 } type pos struct{ Position []track `json:"pos"` }

 x := pos{ Position:[{Lp:"DEMO" , 
 Lat:"-33.3244",Lon:"-33.391134",Speed:"80", } ]}

 Somebody gave me a hand with this:

 track := make(pos,1)
 track[0].Lp = "EEE"
 track[0].Lat = "-23.243423"
 track[0].Lon = "-24.2344123"
 track[0].Speed = "50"

 Data2Send := pos{track}

 But it doesn't keep "pos" when I check Data2Send with 
 fmt.Printf("%v",Data2Send).
 Any idea? "Is any out there?"

 Thanks

 -- 
 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.
>>
>
>
> -- 
> Tomás González Dowling | Comtom Tech
>

-- 
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] issue on export a C static library from Go(CGO)via GCCGO compiler on IBM-AIX -PPC(unix) box

2019-02-18 Thread Lei Ma
HI team :

i am facing an issue on export a C static library from Go via GCCGO 
compiler on IBM-AIX -PPC(unix) box. 
my GO code(wrapper.go)  as   below :

package main

//#include 
//#include 
import "C"
import "fmt"

//export printHello
func printHello() {
fmt.Println("hello nuts!")
}


func main() {
// for c build
}

the command i used to compile it  is  : 
 go build -compiler gccgo -buildmode=c-archive -o caculator.a  -gccgoflags 
'-lgo -static' wrapper.go

then i got a  c static library  caculator.a , then  i use it in a c program 
as below :

#include 
#include 
#include "caculator.h"
int main()
{
  int a=12;
  int b=13;
  printf("Hello, let's test caculator!");
  printHello();
  printf("result:%d",12131231);
}

then i tried compile this c program with : gcc -o app  main.c caculator.a 
-pthread

then i got a exec file  app  
but  when  i tried to run it  , it seems run into a deadlock , nothing 
print  out 

the solution works great  on a 86_64 linux  box with  Go C compiler 
(non-GCCGO)...


got  stuck  with this issue above one week , any thought on this ?

thanks 

-- 
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] Issue using json with array

2019-02-02 Thread Tomás González Dowling
Not sure if that was a question, Juan. But you can use Marshal method in
the encoding/json package to avoid using make. There are some examples in
the official docs: https://golang.org/pkg/encoding/json/#example_Marshal

Hope that it helps :)

El mié., 19 dic. 2018 a las 9:44, Juan Mamani ()
escribió:

> Thanks a lot for your reply!!  You are right it's working.
>
> But, it could be possible to avoid calling "make"...
>
> El mié., 19 de dic. de 2018 a la(s) 08:14, Ozone Kawakami (
> kawakami.oz...@gmail.com) escribió:
>
>> Your code `make(pos, 1)` seems to be typo.
>> The fixed version works well.
>> https://play.golang.org/p/gnLe_Xi2-nb
>>
>> 2018年12月19日(水) 10:40 Juan Mamani :
>>
>>> I'm not an expert but I do my best.
>>>
>>> Original  json format required:
>>> { "pos": [{ "lp" : "WISE-12", "lat": "-33,43565400", "lon" :
>>> "-70,60552700", "speed" : "102" }]
>>> }
>>>
>>> Json autogenerated from: https://mholt.github.io/json-to-go/ (lazy
>>> style but it works. Even more when my boss is surrounding like a shark!
>>> jajaa)
>>>
>>> type AutoGenerated struct { Pos []struct { Lp string
>>> `json:"license_plate"` Lat string `json:"lat"` Lon string `json:"lon"`
>>> Speed string `json:"speed"` } `json:"pos"` }
>>>
>>> So I tried more fancy style but it doesn´t work:(
>>>
>>> type track struct{ Lp string `json:"license_plate"` Lat string
>>> `json:"lat"` Lon string `json:"lon"`
>>> Speed string `json:"speed"`
>>> } type pos struct{ Position []track `json:"pos"` }
>>>
>>> x := pos{ Position:[{Lp:"DEMO" ,
>>> Lat:"-33.3244",Lon:"-33.391134",Speed:"80", } ]}
>>>
>>> Somebody gave me a hand with this:
>>>
>>> track := make(pos,1)
>>> track[0].Lp = "EEE"
>>> track[0].Lat = "-23.243423"
>>> track[0].Lon = "-24.2344123"
>>> track[0].Speed = "50"
>>>
>>> Data2Send := pos{track}
>>>
>>> But it doesn't keep "pos" when I check Data2Send with
>>> fmt.Printf("%v",Data2Send).
>>> Any idea? "Is any out there?"
>>>
>>> Thanks
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to golang-nuts+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Tomás González Dowling | Comtom Tech

-- 
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] Issue using json with array

2018-12-19 Thread Ozone Kawakami
Your code `make(pos, 1)` seems to be typo.
The fixed version works well.
https://play.golang.org/p/gnLe_Xi2-nb

2018年12月19日(水) 10:40 Juan Mamani :

> I'm not an expert but I do my best.
>
> Original  json format required:
> { "pos": [{ "lp" : "WISE-12", "lat": "-33,43565400", "lon" :
> "-70,60552700", "speed" : "102" }]
> }
>
> Json autogenerated from: https://mholt.github.io/json-to-go/ (lazy style
> but it works. Even more when my boss is surrounding like a shark! jajaa)
>
> type AutoGenerated struct { Pos []struct { Lp string
> `json:"license_plate"` Lat string `json:"lat"` Lon string `json:"lon"`
> Speed string `json:"speed"` } `json:"pos"` }
>
> So I tried more fancy style but it doesn´t work:(
>
> type track struct{ Lp string `json:"license_plate"` Lat string
> `json:"lat"` Lon string `json:"lon"`
> Speed string `json:"speed"`
> } type pos struct{ Position []track `json:"pos"` }
>
> x := pos{ Position:[{Lp:"DEMO" ,
> Lat:"-33.3244",Lon:"-33.391134",Speed:"80", } ]}
>
> Somebody gave me a hand with this:
>
> track := make(pos,1)
> track[0].Lp = "EEE"
> track[0].Lat = "-23.243423"
> track[0].Lon = "-24.2344123"
> track[0].Speed = "50"
>
> Data2Send := pos{track}
>
> But it doesn't keep "pos" when I check Data2Send with
> fmt.Printf("%v",Data2Send).
> Any idea? "Is any out there?"
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Issue using json with array

2018-12-19 Thread Juan Mamani
Thanks a lot for your reply!!  You are right it's working.

But, it could be possible to avoid calling "make"...

El mié., 19 de dic. de 2018 a la(s) 08:14, Ozone Kawakami (
kawakami.oz...@gmail.com) escribió:

> Your code `make(pos, 1)` seems to be typo.
> The fixed version works well.
> https://play.golang.org/p/gnLe_Xi2-nb
>
> 2018年12月19日(水) 10:40 Juan Mamani :
>
>> I'm not an expert but I do my best.
>>
>> Original  json format required:
>> { "pos": [{ "lp" : "WISE-12", "lat": "-33,43565400", "lon" :
>> "-70,60552700", "speed" : "102" }]
>> }
>>
>> Json autogenerated from: https://mholt.github.io/json-to-go/ (lazy style
>> but it works. Even more when my boss is surrounding like a shark! jajaa)
>>
>> type AutoGenerated struct { Pos []struct { Lp string
>> `json:"license_plate"` Lat string `json:"lat"` Lon string `json:"lon"`
>> Speed string `json:"speed"` } `json:"pos"` }
>>
>> So I tried more fancy style but it doesn´t work:(
>>
>> type track struct{ Lp string `json:"license_plate"` Lat string
>> `json:"lat"` Lon string `json:"lon"`
>> Speed string `json:"speed"`
>> } type pos struct{ Position []track `json:"pos"` }
>>
>> x := pos{ Position:[{Lp:"DEMO" ,
>> Lat:"-33.3244",Lon:"-33.391134",Speed:"80", } ]}
>>
>> Somebody gave me a hand with this:
>>
>> track := make(pos,1)
>> track[0].Lp = "EEE"
>> track[0].Lat = "-23.243423"
>> track[0].Lon = "-24.2344123"
>> track[0].Speed = "50"
>>
>> Data2Send := pos{track}
>>
>> But it doesn't keep "pos" when I check Data2Send with
>> fmt.Printf("%v",Data2Send).
>> Any idea? "Is any out there?"
>>
>> Thanks
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Issue using json with array

2018-12-18 Thread Juan Mamani
I'm not an expert but I do my best.

Original  json format required:
{ "pos": [{ "lp" : "WISE-12", "lat": "-33,43565400", "lon" : 
"-70,60552700", "speed" : "102" }] 
} 

Json autogenerated from: https://mholt.github.io/json-to-go/ (lazy style 
but it works. Even more when my boss is surrounding like a shark! jajaa)

type AutoGenerated struct { Pos []struct { Lp string `json:"license_plate"` 
Lat string `json:"lat"` Lon string `json:"lon"` Speed string `json:"speed"` 
} `json:"pos"` }

So I tried more fancy style but it doesn´t work:(

type track struct{ Lp string `json:"license_plate"` Lat string `json:"lat"` 
Lon string `json:"lon"`
Speed string `json:"speed"`
} type pos struct{ Position []track `json:"pos"` }

x := pos{ Position:[{Lp:"DEMO" , 
Lat:"-33.3244",Lon:"-33.391134",Speed:"80", } ]}

Somebody gave me a hand with this:

track := make(pos,1)
track[0].Lp = "EEE"
track[0].Lat = "-23.243423"
track[0].Lon = "-24.2344123"
track[0].Speed = "50"

Data2Send := pos{track}

But it doesn't keep "pos" when I check Data2Send with 
fmt.Printf("%v",Data2Send).
Any idea? "Is any out there?"

Thanks

-- 
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] Issue with creating file on aws lambda

2018-10-16 Thread Jim Ancona
I'm pretty sure that the only writeable file system on Lambda in under
/tmp. You're not checking the error return from os.MkdirAll, but that call
is probably failing before you get to os.Create. Also keep in mind that
each Lambda instance is limited to 512 MB of /tmp space:
https://docs.aws.amazon.com/lambda/latest/dg/limits.html

Jim

On Tue, Oct 16, 2018 at 3:46 PM AE  wrote:

> Hello,
>
> I am trying to make function which will down file fro aws s3 and do some
> image resizing. I am having issue with os.Create, when I run locally on ec2
> machine it works fine but when I run on lambda directly I get error file
> not found
>
>
> package main
> import (
> "github.com/aws/aws-sdk-go/aws"
> "github.com/aws/aws-sdk-go/aws/session"
> "github.com/aws/aws-sdk-go/service/s3"
> "github.com/aws/aws-sdk-go/service/s3/s3manager"
> _ "github.com/aws/aws-lambda-go/lambda"
> _ "github.com/nfnt/resize"
>_ "image/jpeg"
> "fmt"
> "os"
>
> )
> type MyEvent struct {
> Name string `json:"name"`
> }
>
> func HandleRequest() (string, error) {
> runResize(
> "5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg")
> return fmt.Sprintf("Hello"), nil
> }
>
> func main() {
>  //   lambda.Start(HandleRequest)
> runResize("5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg")
>
> }
>
> func runResize(item_name string) {
> bucket := "bucket"
> folder_name := "images/users/original/"
> folder_name_220x220 := "images/users/220x220/"
> folder_name_250x250 := "images/users/250x250/"
> folder_name_500x500 := "images/users/500x500/"
> folder_name_large := "images/users/large/"
>
>
>
>
> createFolder(folder_name)
> createFolder(folder_name_220x220)
> createFolder(folder_name_250x250)
> createFolder(folder_name_500x500)
> createFolder(folder_name_large)
>
>
>
> item := folder_name + item_name
>
> fmt.Printf("Creating file %q \n", item)
> file, err :=  os.Create(item)
>
> if err != nil {
>
> exitErrorf("Unable to open file %q", err)
>
> }
> defer file.Close()
> sess, _ := session.NewSession({
> Region: aws.String("us-east-1")},
> )
> downloader := s3manager.NewDownloader(sess)
> numBytes, err := downloader.Download(file,
> {
> Bucket: aws.String(bucket),
> Key:aws.String(item),
> })
>
> if err != nil {
>
> exitErrorf("Unable to download item %q, %v", item, err)
>
> }
>fmt.Println("Processed", file.Name(), numBytes, "bytes")
> }
> func createFolder(folder_name string) {
> if _, err := os.Stat(folder_name); os.IsNotExist(err) {
> os.MkdirAll(folder_name, os.ModePerm)
> fmt.Printf("Folder created %q \n", folder_name)
> }
> }
>
> func exitErrorf(msg string, args ...interface{}) {
>
> fmt.Fprintf(os.Stderr, msg+"\n", args...)
>
> os.Exit(1)
>
> }
>
>
>
> Here how I build the code for deployment
>
>
> GOOS=linux go build -v -ldflags '-d -s -w' -a -tags netgo -installsuffix
> netgo -o resize && zip deployment.zip resize
>
>
> and error I am getting
>
>
> Unable to open file "open
> images/users/original/5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg:
> no such file or directory"
>
> This error i thrown on create on in LAMBDA
>
>
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Issue with creating file on aws lambda

2018-10-16 Thread AE
Hello,

I am trying to make function which will down file fro aws s3 and do some 
image resizing. I am having issue with os.Create, when I run locally on ec2 
machine it works fine but when I run on lambda directly I get error file 
not found 


package main
import ( 
"github.com/aws/aws-sdk-go/aws" 
"github.com/aws/aws-sdk-go/aws/session" 
"github.com/aws/aws-sdk-go/service/s3" 
"github.com/aws/aws-sdk-go/service/s3/s3manager" 
_ "github.com/aws/aws-lambda-go/lambda" 
_ "github.com/nfnt/resize" 
   _ "image/jpeg" 
"fmt" 
"os" 

) 
type MyEvent struct { 
Name string `json:"name"` 
}

func HandleRequest() (string, error) { 
runResize("5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg") 
return fmt.Sprintf("Hello"), nil 
} 

func main() { 
 //   lambda.Start(HandleRequest) 
runResize("5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg") 

} 

func runResize(item_name string) { 
bucket := "bucket" 
folder_name := "images/users/original/" 
folder_name_220x220 := "images/users/220x220/" 
folder_name_250x250 := "images/users/250x250/" 
folder_name_500x500 := "images/users/500x500/" 
folder_name_large := "images/users/large/" 


 

createFolder(folder_name) 
createFolder(folder_name_220x220) 
createFolder(folder_name_250x250) 
createFolder(folder_name_500x500) 
createFolder(folder_name_large) 

 

item := folder_name + item_name 

fmt.Printf("Creating file %q \n", item) 
file, err :=  os.Create(item) 

if err != nil { 

exitErrorf("Unable to open file %q", err) 

} 
defer file.Close() 
sess, _ := session.NewSession({ 
Region: aws.String("us-east-1")}, 
) 
downloader := s3manager.NewDownloader(sess) 
numBytes, err := downloader.Download(file, 
{ 
Bucket: aws.String(bucket), 
Key:aws.String(item), 
}) 

if err != nil { 

exitErrorf("Unable to download item %q, %v", item, err) 

} 
   fmt.Println("Processed", file.Name(), numBytes, "bytes")  
} 
func createFolder(folder_name string) { 
if _, err := os.Stat(folder_name); os.IsNotExist(err) { 
os.MkdirAll(folder_name, os.ModePerm) 
fmt.Printf("Folder created %q \n", folder_name) 
} 
} 

func exitErrorf(msg string, args ...interface{}) { 

fmt.Fprintf(os.Stderr, msg+"\n", args...) 

os.Exit(1) 

}



Here how I build the code for deployment


GOOS=linux go build -v -ldflags '-d -s -w' -a -tags netgo -installsuffix 
netgo -o resize && zip deployment.zip resize


and error I am getting 


Unable to open file "open 
images/users/original/5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg: 
no such file or directory"

This error i thrown on create on in LAMBDA



Thanks 

-- 
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] issue ? httptest failed to bind newly released port

2018-04-12 Thread leslie . qiwa
Dear all,

I filed one issue at https://github.com/golang/go/issues/24818. This 
issue seems like not happened at regular repeating listen/close calls, but 
only at httptest. Sincenet.setDefaultListenerSockopts already set this 
socket option socket.SO_REUSEADDR, I expect app can reuse this port, or app 
should avoid this behavior? Welcome to hear your thought. Thanks!

Best Regards
Leslie


-- 
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] Issue with log.V and log.${Level}Depth

2017-11-03 Thread Xiaoyi Shi
Hi there,

When combining V() and ${Level}Depth() together, the logging logic becomes
less
clear. For instance, with the retry function below:

```go
func Retry(fn func() error) error {
  var lastErr error
  for attempt := 0; attempt < maxRetries; attempt++ {
backoff.Sleep(attempt)
if lastErr = fn(); lastErr == nil {
  return nil
}
// Determined by -vmodule set for retry().
if glog.V(1) {
  // Using caller info at 1 level up in the call stack.
  glog.WarningDepth(1, fmt.Sprintf("Attempt %d failed: %v", attempt,
lastErr))
}
  }
  if glog.V(1) {
glog.WarningDepth(1, fmt.Sprintf("Exhausted %d retries: %v",
maxRetries, lastErr))
  }
  return lastErr
}
```

In this example, Retry() as a helper function, which performs backoff
retries of fn().
It logs in case fn() fails, but instead of logging with context of Retry()
function,
using the context of the Retry() caller will provide better insights for
debugging.

When use ${Level}Depth() with V(), I would expect the verbose status is
determined while
aware of the depth set. So that -vmodule set for the Retry() caller should
be used for
determine the return value of V().

I propose adding a function called `VDepth(level, depth)`, so that the user
may
hint which caller to use.

Best,
Xiaoyi

-- 
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] Issue with json unMarshall

2017-09-18 Thread as
If your field names match the JSON field names, you don't have to 
explicitly tag them.

On Monday, September 18, 2017 at 6:10:46 AM UTC-7, Anil wrote:
>
> Thanks alot!!
>
> On Monday, 18 September 2017 18:38:49 UTC+5:30, Shawn Milochik wrote:
>>
>> Your struct has all unexported fields. So the json package can't see 
>> them. You have to capitalize the field names. 
>>
>

-- 
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] Issue with json unMarshall

2017-09-18 Thread Anil
Thanks alot!!

On Monday, 18 September 2017 18:38:49 UTC+5:30, Shawn Milochik wrote:
>
> Your struct has all unexported fields. So the json package can't see them. 
> You have to capitalize the field names. 
>

-- 
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] Issue with json unMarshall

2017-09-18 Thread Shawn Milochik
Your struct has all unexported fields. So the json package can't see them.
You have to capitalize the field names.

-- 
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] Issue with json unMarshall

2017-09-18 Thread Anil
package main

import "fmt"
import "encoding/json"

type Rec struct {
recordIdstring `json:"recordId"`
cpmId   string `json:"cpmId"`
tpDataType  string `json:"tpDataType"`
tpData  string `json:"tpData"`
blockId string `json:"blockId"`
}

func main() {

var data = 
[]byte(`{"recordId":"aaa","cpmId":"bbb","tpDataType":"ccc","tpData":"ddd","blockId":"eee"}`)
var app Rec
err := json.Unmarshal(data, )   

fmt.Println(err)
fmt.Printf("%v", app)
}

Output:


{}





This Program prints empty Json. Please help me to resolve this.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Issue building binaries using cgo on macOS Sierra 10.12.4

2017-03-28 Thread Rob Pike
Are you running Xcode 8.3? See https://github.com/golang/go/issues/19741.


-rob


On Tue, Mar 28, 2017 at 7:32 AM,  wrote:

> Hello,
>
> Upgraded my mac to 10.12.4 yesterday, tried to run a binary built using
> go1.8. I immediately get Killed: 9 as output.
>
> The binary includes many C/C++ libraries via cgo but everything was fine
> under 10.12.3
>
> I then built the binary using -ldflags -s and that was OK.
>
> I saw a similar issue on github
>  a while back but that had to
> do with codesign, this doesn't.
>
> Let me know what other info I can provide to help track down the issue or
> if I should open an issue on github?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Issue with Goroutine and http.RedirectHandler

2017-02-20 Thread Rejoy
Hi,

I am trying to create a go routine to direct the request to another url:

go http.ListenAndServe(":8000", 
http.RedirectHandler("https://127.0.0.1:8001",301))

I had earler made a mistake and had typed in "https://127.0.0.1/:8001; for 
the url string.  But now after rectifying the mistake to the above, I am 
still being redirected to the incorrect url.

When I type in the url  ""https://127.0.0.1:8001;, the page is rendered 
correctly.

Is there a need to explicitly stop go routines. Strangely even after 
restarting the m/c, the request is being redirected incorrectly. 

Thanks
Rejoy


-- 
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] Issue #5932 (net: do not wait on EAGAIN from lossy packet conn)

2017-01-05 Thread anner
Hi,

I'd like to respond to #5932 , but can't 
because it is locked.

Earlier we had issues (see comment 17), however it seems to be fixed in 
1.7.4 and also a couple of versions ago (1.5, 1.6).

The tested kernel version is:
Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.73-2+deb7u3 x86_64

I've used the source code from comment 17 to reproduce the issue.

Kind regards,
Anner van Hardenbroek

-- 
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] issue with sending JSON via HTTP

2016-10-25 Thread Henrik Johansson
It seems like you encode the valid json string?
If you have a string that is json you should be able to post the string as
is no?

Just make sure you set the application/json content type.

tis 25 okt. 2016 kl 14:32 skrev Rich :

> Hi All,
>
> I have code that is similar to this:
> https://play.golang.org/p/zZ8EQ-R6cb
>
> When I run it I get the following error:
> 2016/10/25 12:19:56 Body: 400 {"message":"The JSON stream reader doesn't
> support chunking."}
>
> So I changed my code to this:
> https://play.golang.org/p/NYV5SdCtnt
>
> and I get the following error:
> 2016/10/25 12:28:28 Body: 400 {"message":"Expecting an array or an
> object."}
>
> This curl command is successful:
> curl -vv -u m11...@myjob.com:mypas$ -H 'Content-Type:application/json' -X
> POST -d @/home/m1/helloworld.json
> http://someupload.myjob.com:8080/events/com.myjob.upload
>
>
> helloworld.json looks like this:
> {
>   "Name": "Operational Demo MR",
>   "greeting": "Hello  World"
> }
>
> I am not sure what it's looking for... any help would be appreciated.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] issue with sending JSON via HTTP

2016-10-25 Thread Rich
Hi All,

I have code that is similar to this:
https://play.golang.org/p/zZ8EQ-R6cb

When I run it I get the following error:
2016/10/25 12:19:56 Body: 400 {"message":"The JSON stream reader doesn't 
support chunking."}

So I changed my code to this:
https://play.golang.org/p/NYV5SdCtnt

and I get the following error:
2016/10/25 12:28:28 Body: 400 {"message":"Expecting an array or an object."}

This curl command is successful:
curl -vv -u m11...@myjob.com:mypas$ -H 'Content-Type:application/json' -X 
POST -d @/home/m1/helloworld.json 
http://someupload.myjob.com:8080/events/com.myjob.upload


helloworld.json looks like this:
{
  "Name": "Operational Demo MR",
  "greeting": "Hello  World"
}

I am not sure what it's looking for... any help would be appreciated. 


-- 
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] Issue report of golang wiki.

2016-10-19 Thread Andrew Gerrand
The wiki code is correct. r.URL.Path should begin with a slash, always.

I'm not sure what you're doing that is different. That wiki code is tested,
though.

On 19 October 2016 at 21:15, KIDJourney  wrote:

> Hi every one .
> I am new guy to golang.
> When I am reading golang wiki about web development I find a small
> issue in the article, Here is the wiki page i read https://golang.org/doc/
> articles/wiki/#tmp_11 .
> At the section of Validation, it creates a regexp to valid and get the
> file name.
>
>
> var validPath = regexp.MustCompile("^/(edit|save|view)/([a-zA-Z0-9]+)$")
> // Then used in
> title := validPath.FindStringSubmatch(r.URL.Path)
>
> But this regex expression is wrong, it can't get the correct file name
> because the path doesn't start with '/'.
> I think the correct  regex expression should be
>
> var validPath = regexp.MustCompile("/(edit|save|view)/([a-zA-Z0-9]+)$")
>
> and it works well for me .
>
> is the wiki incorrect or just i did something wrong ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.