Re: [go-nuts] Accessing css and js files in HTML served by Go

2019-05-06 Thread Miguel Angel Rivera Notararigo
More than magic, it is a global convention. I guess it could be interpreted
as: when you access a directory, the web server will index its content and
will show you a list of links, if you want to override this behavior, you
could create your own index.

See
https://github.com/golang/go/blob/b68624464dc41ffb09b9ee5314d3455904acd2a8/src/net/http/fs.go#L543

-- 
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] Enabling go's race detector working over SQL barrier

2019-05-06 Thread Jan Mercl
On Mon, May 6, 2019 at 6:56 AM Neven Miculinić
 wrote:

> Is there some project going into this direction?

Not sure if relevant: https://godoc.org/modernc.org/ql

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


[go-nuts] How to run a go method on multiple cores ?

2019-05-06 Thread Nitish Saboo
Hi,

I want a go method to run on multiple cores.The go method is returning an 
object. Can we achieve this using goroutine ?
How can I achieve 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] How to run a go method on multiple cores ?

2019-05-06 Thread Jan Mercl
On Mon, May 6, 2019 at 1:11 PM Nitish Saboo  wrote:
>
> Hi,
>
> I want a go method to run on multiple cores.The go method is returning an 
> object. Can we achieve this using goroutine ?
> How can I achieve this ?

In the first approximation, to run a a function/method f() in a
goroutine on N cores/threads, provided N is equal GOMAXPROCS, execute
`go f()` N times.

Why do you care about "stick to core"? If the goroutines have work to
do, they will get spread by the scheduler between threads/cores
anyway.

-- 
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] Golang - mongodb watch for specific data

2019-05-06 Thread afriyie . abraham
Hi, 

I have this data or document in mongodb.

{
 "nfInstanceId": "3fa85f64-5717-4562-b3fc-2c963f66af37",
 "nfType": [
 "AMF"
 ],
 "nfStatus": [
 "string"
 ],
 "sNssais": [{
 "sst": 1,
 "sd": "sd1"
 }
],
 "nsiList": [
 "string"
 ],
 "ipv4Addresses": [
 "198.51.100.100"
 ],
 "allowedNssais": [{
 "sst": 0,
 "sd": "string"
 }],
 "priority": 0,
  "load": 0,
 "amfInfo": {
 "amfSetId": "3fa85f64-5717-4562-b3fc-2c963f66afbb",
 "taiList": [{
 "plmnId": {
 "mcc": "string",
 "mnc": "string"
 },
 "tac": "string"
 }],
 "n2InterfaceAmfInfo": {
 "ipv4EndpointAddress": [
 "198.51.100.100"
 ]
 }
 }
}



Can anyone help me write a golang change stream to get notification for this
 data when there is an update to this concument using
the nfType key as filter. 

-- 
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] How to run a go method on multiple cores ?

2019-05-06 Thread Nitish Saboo
Thanks Jan.

type Y struct {

M string
N string

}

func initalize() Y{
// I have a func that return an object ob type Y.
}
var obj1 Y  = go  initalize()
var obj2 Y  = go  initalize()

Let me know how to call a go routine in this case, because when I am doing
it in this way I am getting compilation error.

Thanks.

On Mon, May 6, 2019 at 4:55 PM Jan Mercl <0xj...@gmail.com> wrote:

> On Mon, May 6, 2019 at 1:11 PM Nitish Saboo 
> wrote:
> >
> > Hi,
> >
> > I want a go method to run on multiple cores.The go method is returning
> an object. Can we achieve this using goroutine ?
> > How can I achieve this ?
>
> In the first approximation, to run a a function/method f() in a
> goroutine on N cores/threads, provided N is equal GOMAXPROCS, execute
> `go f()` N times.
>
> Why do you care about "stick to core"? If the goroutines have work to
> do, they will get spread by the scheduler between threads/cores
> anyway.
>

-- 
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] How to run a go method on multiple cores ?

2019-05-06 Thread Jan Mercl
On Mon, May 6, 2019 at 1:39 PM Nitish Saboo  wrote:

> type Y struct {
>
> M string
> N string
>
> }
>
> func initalize() Y{
> // I have a func that return an object ob type Y.
> }
> var obj1 Y  = go  initalize()

No need to write Y above, the type will be inferred. However, see
https://golang.org/ref/spec#Go_statements The go statement is not an
expression while the `var foo = expr` requires an expression.

-- 
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] large slice literals and go-guru

2019-05-06 Thread David Wahlstedt
Hello,

I'm working on a project where there is a very (machine generated) large 
slice literal in the source tree: around 6MB. The slice is declared in a 
separate file, and it contains instances of an interface.

Each time I use go-guru (go-guru-referrers, for example) in emacs, it takes 
a while before it completes, sometimes even a minute or so.

Maybe it's a bad idea to have such a large slice literal in the code. It is 
machine generated, and the data could also easily be fed in as a JSON or 
CSV file, read in during initialization. But then we will get other issues: 
copy this into the container where it is to be run, etc.

Are there any pragmas / annotations that can be added to source files, to 
indicate that go-guru et al should ignore them?

Best regards,
David

-- 
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] How to run a go method on multiple cores ?

2019-05-06 Thread Michel Levieux
Hello,

Is:

type Y struct {

M string
N string

}

func initalize() Y{
// I have a func that return an object ob type Y.
}

var obj1 Y
go func() {
obj1 = initalize()
}()

var obj2 Y
go func() {
obj2 = initalize()
}()

What you are looking for?

Le lun. 6 mai 2019 à 13:59, Jan Mercl <0xj...@gmail.com> a écrit :

> On Mon, May 6, 2019 at 1:39 PM Nitish Saboo 
> wrote:
>
> > type Y struct {
> >
> > M string
> > N string
> >
> > }
> >
> > func initalize() Y{
> > // I have a func that return an object ob type Y.
> > }
> > var obj1 Y  = go  initalize()
>
> No need to write Y above, the type will be inferred. However, see
> https://golang.org/ref/spec#Go_statements The go statement is not an
> expression while the `var foo = expr` requires an expression.
>
> --
> 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] large slice literals and go-guru

2019-05-06 Thread Tamás Gulácsi
As a workaround, you may try to move the large slice into a separate package.

-- 
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: the Dominance of English in Programming Languages

2019-05-06 Thread lgodio2
this issue involves much more than Go code For example , we for whom 
English is not our native language use 'Google translate' to translate our 
golang-nuts questions into English and the golang-nuts responses back to 
our native language.  The second translation often produces produces 
very-strange (and often laughable) native language translations. So I think 
it is safe to conclude the first translation produces similar things in 
English because many of the golang-nuts responses indicate  gross 
misunderstanding of original question.

Some golang-nuts members are native Americans who have very little 
tolerance for non-American English  

On Saturday, May 4, 2019 at 6:15:00 PM UTC-4, Chris Burkert wrote:
>
> Some background why I was asking this: I have a history with 
> Squeak/Smalltalk and how Alan Kay worked with children. At work I also 
> teach 14/15 year old pupils during their 2 weeks internship and that is 
> simply too short to show them something about programming especially when 
> this is just one topic out of many. We usually convert numbers between 
> decimal, octal, binary and hexadecimal on the whiteboard. And because they 
> just knew 0-9 so far it becomes a sudden insight to some of them. These few 
> kids usually want to learn more (convert numbers programmatically) but 
> because they are intrinsically motivated the English language is not a 
> hurdle for them. That’s why I was wondering about the article.
>
> Thanks for all your comments. Reading the different perspectives about the 
> topic fascinates me a lot.
>
> Chris Burkert > schrieb am Mo. 29. Apr. 
> 2019 um 07:35:
>
>> I recently read an article (German) about the dominance of English in 
>> programming languages [1]. It is about the fact that keywords in a language 
>> typically are English words. Thus it would be hard for non English speakers 
>> to learn programming - argue the authors.
>>
>> I wonder if there is really demand for that but of course it is weird to 
>> ask that on an English list.
>>
>> I also wonder if it would be possible on a tooling level to support 
>> keywords in other languages e.g. via build tags: // +language german
>>
>> Besides keywords we have a lot of names for functions, methods, structs, 
>> interfaces and so on. So there is definitely more to it.
>>
>> While such a feature may be beneficial for new programmers, to me it 
>> comes with many downsides like: readability, ambiguous naming / clashes, 
>> global teams ...
>>
>> I also believe the authors totally miss the point that learning Go is 
>> about to learn a language as it is because it is the language of the 
>> compiler.
>>
>> However I find the topic interesting and want to hear about your opinions.
>>
>> thanks - Chris
>>
>> 1: 
>>
>> https://www.derstandard.de/story/2000101285309/programmieren-ist-fuer-jeden-aber-nur-wenn-man-englisch-spricht
>>
>

-- 
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] Accessing css and js files in HTML served by Go

2019-05-06 Thread Richard Tenney
Hi. I remain mystified. I tried your suggestion, but it didn't work.

This is .../learn/main.go
func main() {

http.HandleFunc("/", handleRoot)
http.Handle("/css/", http.FileServer(http.Dir("webpages/css")))
http.Handle("/js/", http.FileServer(http.Dir("webpages/js")))

fmt.Println("listening on port 8877")
http.ListenAndServe(":8877", nil)
}


The files aren't found -- as soon as  http://127.0.0.1:8877/ is loaded the
two error messages produced are:

Refused to apply style from 'http://127.0.0.1:8877/css/main.css' because
its MIME type ('text/plain') is not a supported stylesheet MIME type, and
strict MIME checking is enabled.
127.0.0.1/:6 GET http://127.0.0.1:8877/js/file.js net::ERR_ABORTED 404 (Not
Found)


But simply displaying .../learn/webpages/main.html via chrome works
just fine.

For the record,  .../learn/webpages/main.html:









 file location exercise 





.../learn/webpages/css/main.css:
body {
background-color: Azure;
color: blue
}

and .../learn/webpages/js/file.js:
function f1() {
alert("Hello from .../learn/webpages/js/file.js")
}

So, I'm still in need of help.

Thanks!

On Mon, May 6, 2019 at 1:02 AM Burak Serdar  wrote:

> On Sat, May 4, 2019 at 10:20 PM ThisEndUp  wrote:
> >
> > I am thoroughly frustrated. I have a file named main.html that
> references a css and a js file.
> >
> > Here's the relevant portion.
> > 
> > 
> > 
> > 
> > 
> >
> > This is in a subdirectory of my GOPATH/src, named learn/webpages, and
> the css and js files are in subdirectories of that, i.e.,
> learn/webpages/css/main.css and learn/webpages/js/file.js
> >
> > When I open the file main.html in my Chrome browser, it behaves just as
> I'd expect it to.
> >
> > When I try to serve it up via a go program, main.go in the learn
> directory (i.e., learn/main.go) I can't for the life of me figure out what
> magic configuration of http.HandleFunc, http.FileServer, http.Handle,
> http.StripPrefix, and http.Dir to use to get these files to load. I don't
> want to use absolute paths, since the location of the base directory will
> change over time.
> >
> > Here's the directory structure of the project. I've put a version of
> file.js and main.css into three different places (with slightly different
> contents, so I can tell which one loads, if any does). The ones I want are
> in the appropriate subdirectories of the webpages directory.
> >
> > [learn]
> > [js]
> > file.js
> > [webpages]
> > [css]
> > main.css
> > [js]
> > file.js
> > main.css
> > main.html
> > file.js
> > main.css
> > main.exe
> > main.go
> >
> > Key: [xxx] is a directory and its contents are indented below it.
> >
> > The following does not work, but it's the direction I've been trying.
> The func handleRoot loads the web page, but I can't figure out how to
> access the css and js files. And when the documentation refers to the
> "current directory" is that going to be learn, where main.exe is running,
> or learn/webpages where main.html lives?
> >
> >
> > // main.go
> > package main
> >
> > import (
> > "fmt"
> > "net/http"
> > )
> >
> > func handleRoot(w http.ResponseWriter, r *http.Request) {
> > http.ServeFile(w, r, "webpages/main.html")
> > }
> >
> > func main() {
> > http.HandleFunc("/", handleRoot)
>   ^^
> This will handle requests for "/" to handleRoot, which is correct
>
> >
> > fs := http.FileServer(http.Dir("webpages"))
> > http.Handle("/webpages/", http.StripPrefix("/webpages/", fs))
>   
>
> This will handle requests for /webpages/ to fs, stripping the prefix.
> However, with the HTML file you have, the requests will be /css and
> /js, not /webpages/css or /webpages/js
>
> You could try this:
>
> http.Handle("/css/",http.FileServer(http.Dir("webpages/css"))
> http.Handle("/js/",http.FileServer(http.Dir("webpages/js"))
>
>
> >
> > fmt.Println("listening on port 8899")
> > http.ListenAndServe(":8899", nil)
> > }
> >
> >
> > I've looked at lots of webpages that purport to explain how to do this,
> but haven't yet figured any of them out. Any help will be greatly
> 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.


Re: [go-nuts] Accessing css and js files in HTML served by Go

2019-05-06 Thread ThisEndUp
Hi. Thanks for your explanation. It makes sense.

However, the "magic" I asked about was based on your first suggestion: 
simply use
http.Handle("/", http.FileServer(http.Dir("webpages")))

As I said, it works if the file to be shown is index.html. My question: how 
do I modify that in order to use main.html instead of index.html?

The whole program of my current unsuccessful attempt is in my post above. 
It works to show main.html but finds neither the css nor the js files.


Thanks!

On Monday, May 6, 2019 at 3:02:17 AM UTC-4, Miguel Angel Rivera Notararigo 
wrote:
>
> More than magic, it is a global convention. I guess it could be 
> interpreted as: when you access a directory, the web server will index its 
> content and will show you a list of links, if you want to override this 
> behavior, you could create your own index.
>
> See 
> https://github.com/golang/go/blob/b68624464dc41ffb09b9ee5314d3455904acd2a8/src/net/http/fs.go#L543
>

-- 
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] Accessing css and js files in HTML served by Go

2019-05-06 Thread ThisEndUp
Oops, I left a few lines at the top of main.go out of the post: here's the 
whole thing:
// main.go
package main

import (
"fmt"
"net/http"
)

func handleRoot(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "webpages/main.html")
}

func main() {

http.HandleFunc("/", handleRoot)
http.Handle("/css/", http.FileServer(http.Dir("webpages/css")))
http.Handle("/js/", http.FileServer(http.Dir("webpages/js")))
fmt.Println("listening on port 8877")
http.ListenAndServe(":8877", nil)
}

>
>>

-- 
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] Accessing css and js files in HTML served by Go

2019-05-06 Thread Miguel Angel Rivera Notararigo
You can write your own handler that serve static files and use main.html as
index, but, the main.html name is mandatory? It breaks the convention

-- 
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] Accessing css and js files in HTML served by Go

2019-05-06 Thread Jan Mercl
On Mon, May 6, 2019 at 6:11 PM ThisEndUp  wrote:

That listing is terrible. Colors aside, some parts of text has
contrast like 10%. Please post source code/snippets at play.golang.org
or include in in the email as plain text only, i.e.black on white.
It's the most readable option. 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] What is the current status of generics in Go?

2019-05-06 Thread 'kalekold' via golang-nuts
I saw a design document floating about sometime last year and there seemed 
to be a lot of thought going into implementing them? What is the current 
status and where can I read more? 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] Re: How to run a go method on multiple cores ?

2019-05-06 Thread lgodio2
If   func f (n int) []int { is some fcn that requires CPU time 
T (large) to calculate its return value  

And I write :
func main() {
var s [ ] int; 
s1  := f(1)  ;  s1  := f(2) 
...
}

I get  results after CPU time  2 T
?? To obtain results in < 2T time,  can I write  s1  :=  go f(1)  ;  s1  := 
go f(2)

On Monday, May 6, 2019 at 7:11:00 AM UTC-4, Nitish Saboo wrote:
>
> Hi,
>
> I want a go method to run on multiple cores.The go method is returning an 
> object. Can we achieve this using goroutine ?
> How can I achieve 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] binary.Read cgo fields

2019-05-06 Thread Matt Harden
On Sun, May 5, 2019, 06:33 Immueggpain S  wrote:

> Ah, my bad! What I meant was that binary.Read will pad when writing to the
> struct, unlike memcpy.
>

Oh, yes you're right of course.

If you want to serialize a C struct using Go, you're going to have to
mention every field on the Go side.

You could serialize/deserialize using a language independent format like
protobufs (there are many of these formats). Then you can serialize the
data from any language, and deserialize it in any other language.

On Sat, May 4, 2019 at 10:50 AM Matt Harden  wrote:
>
>> Why do you think binary.Read should handle padding for you? Based on the
>> documentation, it would be a bug if it did.
>>
>> On Tue, Apr 30, 2019 at 4:42 AM Immueggpain S 
>> wrote:
>>
>>> I guess I have no other choice then? BTW binary.Read shoud handle
>>> padding automatically.
>>>
>>> On Mon, Apr 22, 2019 at 10:53 AM Ian Lance Taylor 
>>> wrote:
>>>
 On Sat, Apr 20, 2019 at 11:53 AM  wrote:
 >
 > binary.Read can't set unexported fields, right?
 > But my structs are defined in C, and I can't make all C source code
 using capital fields..
 > What could I do?

 Read the fields separately.  That is often a better idea in any case,
 as the result is more portable and avoids problems with structs that
 require padding between fields.

 Ian

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

-- 
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] Accessing css and js files in HTML served by Go

2019-05-06 Thread Burak Serdar
On Mon, May 6, 2019 at 9:47 AM Richard Tenney  wrote:
>
> Hi. I remain mystified. I tried your suggestion, but it didn't work.
>
> This is .../learn/main.go
> func main() {
>
> http.HandleFunc("/", handleRoot)
> http.Handle("/css/", http.FileServer(http.Dir("webpages/css")))
> http.Handle("/js/", http.FileServer(http.Dir("webpages/js")))
>
> fmt.Println("listening on port 8877")
> http.ListenAndServe(":8877", nil)
> }

You need to set the content type on the response. Try something like this:

func rewriteContentType(contentType string,handler http.Handler)  http.Handler {
return http.HandlerFunc( func(wr http.ResponseWriter,req *http.Request) {
wr.Header().Set("Content-Type",contentType)
handler.ServeHTTP(wr,req)
})
}

and then:

 http.Handle("/css/",
rewriteContentType("text/css".http.FileServer(http.Dir("webpages/css"
 http.Handle("/js/",
rewriteContentType("text/javascript".http.FileServer(http.Dir("webpages/js"


This code probably will not compile, but it should give you the idea.




>
>
> The files aren't found -- as soon as  http://127.0.0.1:8877/ is loaded the 
> two error messages produced are:
>
> Refused to apply style from 'http://127.0.0.1:8877/css/main.css' because its 
> MIME type ('text/plain') is not a supported stylesheet MIME type, and strict 
> MIME checking is enabled.
> 127.0.0.1/:6 GET http://127.0.0.1:8877/js/file.js net::ERR_ABORTED 404 (Not 
> Found)
>
>
> But simply displaying .../learn/webpages/main.html via chrome works just fine.
>
> For the record,  .../learn/webpages/main.html:
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  file location exercise 
> 
> 
> 
> 
>
> .../learn/webpages/css/main.css:
> body {
> background-color: Azure;
> color: blue
> }
>
> and .../learn/webpages/js/file.js:
> function f1() {
> alert("Hello from .../learn/webpages/js/file.js")
> }
>
> So, I'm still in need of help.
>
> Thanks!
>
> On Mon, May 6, 2019 at 1:02 AM Burak Serdar  wrote:
>>
>> On Sat, May 4, 2019 at 10:20 PM ThisEndUp  wrote:
>> >
>> > I am thoroughly frustrated. I have a file named main.html that references 
>> > a css and a js file.
>> >
>> > Here's the relevant portion.
>> > 
>> > 
>> > 
>> > 
>> > 
>> >
>> > This is in a subdirectory of my GOPATH/src, named learn/webpages, and the 
>> > css and js files are in subdirectories of that, i.e., 
>> > learn/webpages/css/main.css and learn/webpages/js/file.js
>> >
>> > When I open the file main.html in my Chrome browser, it behaves just as 
>> > I'd expect it to.
>> >
>> > When I try to serve it up via a go program, main.go in the learn directory 
>> > (i.e., learn/main.go) I can't for the life of me figure out what magic 
>> > configuration of http.HandleFunc, http.FileServer, http.Handle, 
>> > http.StripPrefix, and http.Dir to use to get these files to load. I don't 
>> > want to use absolute paths, since the location of the base directory will 
>> > change over time.
>> >
>> > Here's the directory structure of the project. I've put a version of 
>> > file.js and main.css into three different places (with slightly different 
>> > contents, so I can tell which one loads, if any does). The ones I want are 
>> > in the appropriate subdirectories of the webpages directory.
>> >
>> > [learn]
>> > [js]
>> > file.js
>> > [webpages]
>> > [css]
>> > main.css
>> > [js]
>> > file.js
>> > main.css
>> > main.html
>> > file.js
>> > main.css
>> > main.exe
>> > main.go
>> >
>> > Key: [xxx] is a directory and its contents are indented below it.
>> >
>> > The following does not work, but it's the direction I've been trying. The 
>> > func handleRoot loads the web page, but I can't figure out how to access 
>> > the css and js files. And when the documentation refers to the "current 
>> > directory" is that going to be learn, where main.exe is running, or 
>> > learn/webpages where main.html lives?
>> >
>> >
>> > // main.go
>> > package main
>> >
>> > import (
>> > "fmt"
>> > "net/http"
>> > )
>> >
>> > func handleRoot(w http.ResponseWriter, r *http.Request) {
>> > http.ServeFile(w, r, "webpages/main.html")
>> > }
>> >
>> > func main() {
>> > http.HandleFunc("/", handleRoot)
>>   ^^
>> This will handle requests for "/" to handleRoot, which is correct
>>
>> >
>> > fs := http.FileServer(http.Dir("webpages"))
>> > http.Handle("/webpages/", http.StripPrefix("/webpages/", fs))
>>   
>>
>> This will handle requests for /webpages/ to fs, stripping the prefix.
>> However, with the HTML file you have, the requests will be /css and
>> /js, not /webpages/css or /webpages/js
>>
>> You could try this:
>>
>> http.Handle("/css/",http.FileServer(http.Dir("webpages/css"))
>> http.Handle("/js/",http.FileServer(http.Dir("webpages/js"))
>>
>>
>> >
>> > fmt.Println("listening on port 8899")
>> > http.ListenAndServe(":8899", nil)
>> > }
>> >
>> >
>> > I've looked at lots of webpages that purport to explain how to do this, 
>> > but haven't yet figured any of them out. Any help will be greatly 
>> > a

[go-nuts] Using cgo with go modules

2019-05-06 Thread grubian . euhen
Hello,
I am trying to adopt my cgo package with go modules. 
The cgo project I mentioned above is built using simple Makefile so that I 
obtain external shared library(.so on Unixes and .dll on Windows) to link 
external applications(from other modules) with. 
When I try to use this module from the other go module the cgo module will 
be downloaded but failed to build because Makefile won't be run. Is there a 
way to call Makefile during the automatic build of downloaded cgo package 
using `go get` or `go build` from an external module that depends on my cgo 
package?

-- 
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] Accessing css and js files in HTML served by Go

2019-05-06 Thread Richard Tenney
You're right! They're awful.

Here are the files I sent -- this time in black-and-white, fixed width

.../learn/main.go

// main.go
package main

import (
"fmt"
"net/http"
)

func handleRoot(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "webpages/main.html")
}

func main() {

http.HandleFunc("/", handleRoot)
http.Handle("/css/", http.FileServer(http.Dir("webpages/css")))
http.Handle("/js/", http.FileServer(http.Dir("webpages/js")))

fmt.Println("listening on port 8877")
http.ListenAndServe(":8877", nil)
}


.../learn/webpages/main.html
==









 file location exercise 





.../learn/webpages/css/main.css
=
body {
background-color: Azure;
color: blue
}

.../learn/webpages/js/file.js

function f1() {
alert("Hello from .../learn/webpages/js/file.js")
}

On Mon, May 6, 2019 at 12:16 PM Jan Mercl <0xj...@gmail.com> wrote:

> On Mon, May 6, 2019 at 6:11 PM ThisEndUp  wrote:
>
> That listing is terrible. Colors aside, some parts of text has
> contrast like 10%. Please post source code/snippets at play.golang.org
> or include in in the email as plain text only, i.e.black on white.
> It's the most readable option. 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] Using cgo with go modules

2019-05-06 Thread Ian Lance Taylor
On Mon, May 6, 2019 at 12:37 PM  wrote:
>
> Hello,
> I am trying to adopt my cgo package with go modules.
> The cgo project I mentioned above is built using simple Makefile so that I 
> obtain external shared library(.so on Unixes and .dll on Windows) to link 
> external applications(from other modules) with.
> When I try to use this module from the other go module the cgo module will be 
> downloaded but failed to build because Makefile won't be run. Is there a way 
> to call Makefile during the automatic build of downloaded cgo package using 
> `go get` or `go build` from an external module that depends on my cgo package?

We've intentionally steered clear of having `go get` or `go build`
invoke `make`.  Running `make` can literally do anything on your
system.  We don't want that to happen as a side-effect of running the
go tool.  At least for now it has to be an explicit decision by the
user.   In your case you'll have to document the requirement.

Ian

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


Re: [go-nuts] What is the current status of generics in Go?

2019-05-06 Thread Ian Lance Taylor
On Mon, May 6, 2019 at 9:22 AM 'kalekold' via golang-nuts
 wrote:
>
> I saw a design document floating about sometime last year and there seemed to 
> be a lot of thought going into implementing them? What is the current status 
> and where can I read more? Thanks.

There is continuing thought.  There is a lot of feedback at
https://github.com/golang/go/wiki/Go2GenericsFeedback .

Ian

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


Re: [go-nuts] Is renewal of expired context possible?

2019-05-06 Thread Ian Lance Taylor
On Sun, May 5, 2019 at 11:13 AM  wrote:
>
> Hi, Is there a way to renew a context that has already reached a deadline?

No, sorry.

Ian

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


[go-nuts] Simple Go web server that service files

2019-05-06 Thread suntong001
I'm learning Go web server programming and have copied the following 
example:


func Image(w http.ResponseWriter, r *http.Request) {
f, _ := os.Open("images/my.png")
. . . 


It works fine when I'm starting the Go web server with `go run main.go &`. 
I.e., the file "images/my.png" is related to where I started "go run". 
However, it won't be the case when the Go web server is compiled and 
started the other way. 

What's the proper way to make sure it always works, including starting from 
docker container? 

THX!




-- 
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] Is renewal of expired context possible?

2019-05-06 Thread sandeep . kalra
Thanks for confirming.

On Monday, May 6, 2019 at 6:16:49 PM UTC-4, Ian Lance Taylor wrote:
>
> On Sun, May 5, 2019 at 11:13 AM > 
> wrote: 
> > 
> > Hi, Is there a way to renew a context that has already reached a 
> deadline? 
>
> No, sorry. 
>
> Ian 
>

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


[go-nuts] Go 1.12.5 and Go 1.11.10 are released

2019-05-06 Thread Andrew Bonventre
Hello gophers,

We have just released Go versions 1.12.5 and 1.11.10, minor point releases.

This release includes fixes to the compiler, the linker, the go command,
the runtime, and the os package.

View the release notes for more information:
https://golang.org/doc/devel/release.html#go1.12.minor

You can download binary and source distributions from the Go web site:
https://golang.org/dl/

To compile from source using a Git clone, update to the release with
"git checkout go1.12.5" and build as usual.

Thanks to everyone who contributed to the release.

Cheers,
Andy for the Go team

-- 
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] Web access to golang-dev is down

2019-05-06 Thread Liam Breck
But golang-nuts is still working...

-- 
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] How to run a go method on multiple cores ?

2019-05-06 Thread Nitish Saboo
Hi Michel,

Yes, this is what I was looking for.Thankyou..:)

Can we also find the processor on which this go routine is running?

Thanks


On Mon, 6 May 2019, 17:43 Michel Levieux,  wrote:

> Hello,
>
> Is:
>
> type Y struct {
>
> M string
> N string
>
> }
>
> func initalize() Y{
> // I have a func that return an object ob type Y.
> }
>
> var obj1 Y
> go func() {
> obj1 = initalize()
> }()
>
> var obj2 Y
> go func() {
> obj2 = initalize()
> }()
>
> What you are looking for?
>
> Le lun. 6 mai 2019 à 13:59, Jan Mercl <0xj...@gmail.com> a écrit :
>
>> On Mon, May 6, 2019 at 1:39 PM Nitish Saboo 
>> wrote:
>>
>> > type Y struct {
>> >
>> > M string
>> > N string
>> >
>> > }
>> >
>> > func initalize() Y{
>> > // I have a func that return an object ob type Y.
>> > }
>> > var obj1 Y  = go  initalize()
>>
>> No need to write Y above, the type will be inferred. However, see
>> https://golang.org/ref/spec#Go_statements The go statement is not an
>> expression while the `var foo = expr` requires an expression.
>>
>> --
>> 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.