[go-nuts] How to renderer the multiple html pages ?

2019-02-02 Thread Robert Hsiung
Hi all:
I make three html pages as index.html ,wps1.html and wps2.html. The 
three html pages are under the same folder.
The expected flow is to login  index.html first and access wps1 or wps2 by 
index page hyperlink.
And then,I edit the golang source file  and build exe file . But  I launch 
the exe file and found I access the wps1 or wps2 and ocurred the error.
So,How to renderer the multiple html pages ? Any one provide the sample 
solution ? Thanks so much.


BR Robert

-- 
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] lock for assigning to different elements of an array

2019-02-02 Thread robert engels
Actually, in the comments on that paper it states :

A technical note: C++11 essentially prohibits compilers from introducing stores 
that were not written by the programmer. See 1.10 paragraph 22 of the C++ 
standard. Previous versions of the standard did permit such an irksome 
possibility.

I assume Go is the same.

> On Feb 2, 2019, at 5:27 PM, robert engels  wrote:
> 
> I am not sure those critical failures outlined in the paper are possible in 
> Go, certainly not Java, but I’d like to understand more.
> 
> I don’t think the ‘re-using of the memory’ can happen, since it is a local 
> variable, and to be seen by another thread it would be captured in a closure 
> and be protected, and if it was a global variable I think the compiler rules 
> must prevent a using it for temporary storage, since it could mapped to an IO 
> location, etc.
> 
> I’ve never seen the re-use as temporary storage - is there some proven 
> literature on this?
> 
>> On Feb 2, 2019, at 2:35 PM, jake6...@gmail.com  
>> wrote:
>> 
>> Always a good read on why that is still a problem:
>> Benign Data Races: What Could Possibly Go Wrong? 
>> 
>> It is not specific to go, but mostly applies to any language, and is stuff 
>> all developers should know. 
>> 
>> On Friday, February 1, 2019 at 4:58:11 PM UTC-5, Michael Ellis wrote:
>> 
>> 
>> On Friday, February 1, 2019 at 11:11:24 AM UTC-5, robert engels wrote:
>> 
>> for {
>>if A.a > 100 {
>>   break
>> }
>> 
>> 
>> Go routine #2 may never see the value of A.a change and so never exit the 
>> loop.
>> 
>> I'm confused. I can see how that would fail if the test were A.a == 100 
>> since Go routine #1 might increment past 100 before #2 ,  but as written it 
>> seems wrong only if the application logic depends on Go routine #2 exiting 
>> the loop as soon as A.a reaches 100 (as opposed to any time afterward.) 
>> 
>> What am I missing?
>> 
>> 
>> 
>> -- 
>> 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] Re: lock for assigning to different elements of an array

2019-02-02 Thread robert engels
No, you are not even using the mutex in that code...

> On Feb 2, 2019, at 4:43 AM, xue...@gmail.com wrote:
> 
> I think you can change it like below:
>  
> var rm sync.Mutex
> var ts [2]string
> for i, s := range []string{"first", "second"} {
>   i, s := i, s
>   go func(i int, s string){
>   ts[i] = s
>   }(i,s)
> }
> 
> 
> -- 
> 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] lock for assigning to different elements of an array

2019-02-02 Thread robert engels
I am not sure those critical failures outlined in the paper are possible in Go, 
certainly not Java, but I’d like to understand more.

I don’t think the ‘re-using of the memory’ can happen, since it is a local 
variable, and to be seen by another thread it would be captured in a closure 
and be protected, and if it was a global variable I think the compiler rules 
must prevent a using it for temporary storage, since it could mapped to an IO 
location, etc.

I’ve never seen the re-use as temporary storage - is there some proven 
literature on this?

> On Feb 2, 2019, at 2:35 PM, jake6...@gmail.com wrote:
> 
> Always a good read on why that is still a problem:
> Benign Data Races: What Could Possibly Go Wrong? 
> 
> It is not specific to go, but mostly applies to any language, and is stuff 
> all developers should know. 
> 
> On Friday, February 1, 2019 at 4:58:11 PM UTC-5, Michael Ellis wrote:
> 
> 
> On Friday, February 1, 2019 at 11:11:24 AM UTC-5, robert engels wrote:
> 
> for {
>if A.a > 100 {
>   break
> }
> 
> 
> Go routine #2 may never see the value of A.a change and so never exit the 
> loop.
> 
> I'm confused. I can see how that would fail if the test were A.a == 100 since 
> Go routine #1 might increment past 100 before #2 ,  but as written it seems 
> wrong only if the application logic depends on Go routine #2 exiting the loop 
> as soon as A.a reaches 100 (as opposed to any time afterward.) 
> 
> What am I missing?
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

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


[go-nuts] Re: lock for assigning to different elements of an array

2019-02-02 Thread xuejoy
I think you can change it like below:
 

> var rm sync.Mutex
> var ts [2]stringfor i, s := range []string{"first", "second"} {   i, s := 
> i, sgo func(i int, s string){   ts[i] = s   }(i,s)}
>
>
>

-- 
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] url.parse issue if the first character of a url is a number

2019-02-02 Thread xuejoy
If a url frist character is a number like 5abc.cnd.com:443, it will throws 
an error during url.parse()

I checked the url.go source code, and I noticed the root cause is the below 
code( method getschema()):
case '0' <= c && c <= '9' || c == '+' || c == '-' || c == '.':
 if i == 0 {
   return "", rawurl, nil
 }

I thinks it should be a bug, what do you think?

-- 
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] lock for assigning to different elements of an array

2019-02-02 Thread Michael Ellis


On Saturday, February 2, 2019 at 3:36:17 PM UTC-5, Jake Montgomery wrote:
>
> Always a good read on why that is still a problem:
> Benign Data Races: What Could Possibly Go Wrong? 
> 
> It is not specific to go, but mostly applies to any language, and is stuff 
> all developers should know. 
>

Thanks, Jake. That's a good write-up. 

-- 
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] lock for assigning to different elements of an array

2019-02-02 Thread Michael Ellis


On Friday, February 1, 2019 at 5:38:49 PM UTC-5, robert engels wrote:
>
> The pseudo code for the correct code would look like:
>

Robert, thanks very much for the clear explanation and correct example. I'd 
totally forgotten that Go is threaded underneath the hood and was thinking 
only in terms of latencies and pre-emptive scheduling.  I'm amazed that the 
code I've written since diving into Go (six months ago) works at all.  One 
of my control system apps has been running on multiple hosts 24/7 for 
several months with no crashes or problems that look like data races so I 
guess I've been lulled into a false complacency. But you can bet I'll be 
testing it with -race going forward!

-- 
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] lock for assigning to different elements of an array

2019-02-02 Thread jake6502
Always a good read on why that is still a problem:
Benign Data Races: What Could Possibly Go Wrong? 

It is not specific to go, but mostly applies to any language, and is stuff 
all developers should know. 

On Friday, February 1, 2019 at 4:58:11 PM UTC-5, Michael Ellis wrote:
>
>
>
> On Friday, February 1, 2019 at 11:11:24 AM UTC-5, robert engels wrote:
>>
>>
>> for {
>>if A.a > 100 {
>>   break
>> }
>>
>>
>> Go routine #2 may never see the value of A.a change and so never exit the 
>> loop.
>>
>
> I'm confused. I can see how that would fail if the test were A.a == 100 
> since Go routine #1 might increment past 100 before #2 ,  but as written it 
> seems wrong only if the application logic depends on Go routine #2 exiting 
> the loop as soon as A.a reaches 100 (as opposed to any time afterward.) 
>
> What am I missing?
>
>
>>

-- 
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] Diagnose

2019-02-02 Thread Michael Jones
Original was January 22.

On Fri, Feb 1, 2019 at 3:56 PM Michael Jones 
wrote:

> This looks like the question asked a week ago. Look at the first post for
> answers.
>
> On Fri, Feb 1, 2019 at 3:44 PM John  wrote:
>
>> Dear Gophers,
>>  I have made a connect five game, and am planning to make it a website.
>> But first, there is a diagnostic problem. My win function depends on if a
>> points neighbouring 4 dots  ..x.. are all the same type. But if its on the
>> edge it will not run, as it only has 2 neighbours X .. I made this
>> function, but it still wont work, also if there is a way to shorten it I
>> will be glad to use it..:
>> func simple() {
>> if x == "1"|| x == "2"|| x == "3"|| x == "4"|| x == "5"|| x == "6"|| x ==
>> "7"|| x == "8"|| x == "9"|| x == "10"|| x == "11"|| x == "12"|| x == "13"||
>> x == "14"|| x == "15" {
>> if y == "1"|| y == "2"|| y == "3"|| y == "4"|| y == "5"|| y == "6"|| y ==
>> "7"|| y == "8"|| y == "9"|| y == "10"|| y == "11"|| y == "12"|| y == "13"||
>> y == "14"|| y == "15" {
>> wiwi()
>> } else {
>> showBoard()
>> fmt.Println("Sorry you had entered wrong please enter again")
>> fmt.Scanln(,)
>> simple()
>> }
>> }
>> }
>>  Ps it is before the win function in the game function.
>>
>>
>>
>>
>>
>>John
>>
>> --
>> 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.
>>
> --
>
> *Michael T. jonesmichael.jo...@gmail.com *
>
-- 

*Michael T. jonesmichael.jo...@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.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: using docker for compiling

2019-02-02 Thread Keith Brown
Thanks.

At the moment I use a Makefile (different from the above :-) ) .

I suppose I am asking because I want to integrate vim-go with the docker 
build ( docker run -v $PWD:/mnt -w /mnt bash -c "go build main.go" ) 
Was wondering if anyone has done that before. 


On Friday, February 1, 2019 at 7:30:32 PM UTC-5, Space A. wrote:
>
> You simply need 
> docker run <...>
> which will invoke smth like 
> go build
> at the end.
>
> PS: The above Makefile is garbage.
>
>
> пятница, 1 февраля 2019 г., 21:59:53 UTC+3 пользователь Bojan Delić 
> написал:
>>
>> I have Makefile that supports build in docker image, part of it looks 
>> something like this:
>>
>> NAME := 
>> PACKAGE := github.com/username/repo
>>
>>
>> .PHONY: build
>> build: clean gobuild ## Build application
>>
>> .PHONY: gobuild
>> gobuild: LDFLAGS=$(shell ./scripts/gen-ldflags.sh $(VERSION))
>> gobuild:
>>@echo "Building '$(NAME)'"
>>@env go generate -mod=vendor
>>@CGO_ENABLED=0 go build -mod=vendor --ldflags "$(LDFLAGS)" -tags netgo .
>>
>> .PHONY: clean
>> clean: ## Remove build artifacts
>>@echo "==> Cleaning build artifacts..."
>>@rm -fv coverage.txt
>>@find . -name '*.test' | xargs rm -fv
>>@rm -fv $(NAME)
>>
>> .PHONY: build-in-docker
>> build-in-docker:
>>@docker run --rm \
>>   -v $(shell pwd):/go/src/$(PACKAGE) \
>>   -w /go/src/$(PACKAGE) \
>>   -e GO111MODULE=on \
>>   golang:latest \
>>   make build
>>
>>
>> As you can see, there are some external scripts called (like 
>> gen-ldflags.sh) and docker build is just invoking "make build" inside 
>> docker container. I do not use this for CI (GitLab CI is already setup to 
>> use docker images), so that is why I use latest tag (in CI I use explicit 
>> version of Go). 
>>
>>
>> There are some leftovers from earlier times, like mounting working dir to 
>> GOPATH, which is not needed if GO111MODULE is set.
>>
>>
>> On Friday, February 1, 2019 at 4:48:01 AM UTC+1, Keith Brown wrote:
>>>
>>> does anyone use docker golang image to compile? if so,how is your setup?
>>>
>>>

-- 
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] database/sql: NextResultSet API always return false

2019-02-02 Thread sagar puneria
Thank you for investigating.

On Friday, February 1, 2019 at 3:01:35 PM UTC+5:30, Inada Naoki wrote:
>
> Hello, I'm one of maintainer of go-sql-driver/mysql.
>
> When there is only one result set, you don't need NextResultSet().
> See this example.
>
> https://play.golang.org/p/rhm4Xp6WejB
>
> Then, when you have multi result set, you need to call NextResultSet() 
> once to get 2nd result set.
> See this example.
>
> https://play.golang.org/p/C-le-V7NWBx
>
> After reading Lutz's sample code.  I found lib/pq has different semantics.
> I'm not sure which is the right semantics, intended by database/sql APIs.
>
> 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.