[go-nuts] Unique GO language features

2020-08-21 Thread joseph.p...@gmail.com
I really like the 'defer' statement and think it would be a useful addition 
to other programming languages.

The feature where GO performs escape analysis and promotes stack variables 
to the heap: Did that originate with GO or was it first implemented 
elsewhere?

Thanks,

Joe

-- 
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/aa60d506-7b98-49fd-8017-9601c18ff09dn%40googlegroups.com.


[go-nuts] Thread safe tree library?

2021-01-05 Thread joseph.p...@gmail.com
Is there a simple tree library that is thread safe? 

If I have to write one for myself, do I have to set locks on nodes as I 
walk the tree to 
prevent another thread from changing nodes that are 'above' 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/6597198c-c439-4a1e-bff2-a2176204b272n%40googlegroups.com.


Re: [go-nuts] Thread safe tree library?

2021-01-05 Thread joseph.p...@gmail.com
Well, I think I only need to lock on writes, and it'll be easier if I just 
lock the entire tree on writes. Reads will be the majority of the 
operations by far. This is for a bit of caching before we go to a K/V 
database like REDIS, etc.

On Tuesday, January 5, 2021 at 5:16:36 PM UTC-8 k.alex...@gmail.com wrote:

> On Tue, Jan 5, 2021, 6:59 PM Nathan Fisher  wrote:
>
>> Does write only locking provide read correctness? I would’ve thought 
>> based on the memory model it could cause issues?
>>
>> https://golang.org/ref/mem#tmp_2
>>
>
> It depends on your notion of "read correctness", specifically when you 
> consider each read to have occurred with respect to its concurrent writes. 
> Linearizability may be a weaker guarantee than you want, and that's okay.
>
> Linearizability requires that, for each operation, you can pick some point 
> between the start and end of an operation when it can be said to have 
> "occurred". When you consider all the operations in that order, the results 
> you see must be the same as a sequential execution.
>
> In the case I have described, we can pick a linearization point for reads 
> just before the last write which they passed on their way down the tree. 
> The reads should then see all the writes which happened prior to this point.
>
> This isn't the order the operations enter the root, but linearizability 
> doesn't care. It doesn't have an opinion on when overlapping operations 
> "occur" with respect to one another.
>
> I don't think using a happens-before relation for the program order seen 
> by each goroutine is going to cause a problem with respect to choosing 
> these linearization points, but maybe I'm missing something.
>
> Maybe also there is a standardized notion of read correctness that you're 
> referring to which I am not aware of.
>

-- 
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/8d97ad06-f7e6-4fdd-8ec4-0803e0ad3dd1n%40googlegroups.com.


Re: [go-nuts] Thread safe tree library?

2021-01-10 Thread joseph.p...@gmail.com
Thanks! You all have given me much to look at.

-joe

On Friday, January 8, 2021 at 2:56:46 PM UTC-8 k.alex...@gmail.com wrote:

> I was thinking of potential issues if you rebalance the tree as an example.
>>
>> I’m not certain what issues could arise as I’ve never considered a 
>> concurrent data structure that lacks some kind of synchronisation for both 
>> read and writes unless it’s immutable copy-on-write or similar.
>>
>> Do you happen to have references available for further research?
>>
>> You do have to be careful when rebalancing. The goal is to make the 
> rebalancing appear atomic to other reads as they go down the tree. IIRC a 
> technique to do this involves recreating the nodes involved in the 
> rebalance and completing the rebalance by updating a single edge at once. 
> That sounds a lot to me like copy-on-write but IIRC it doesn't require 
> copying the entire subtree.
>
> You might also be interested in some of the below references, although 
> they're all on lock-free and wait-free options. Disclaimer: They're all 
> from my Ph.D advisor. I was working in his lab when most of this work was 
> being done. Most of what I've posted here is based on my memory of their 
> approach.
>
> https://dl.acm.org/doi/10.1145/3391438  
> https://dl.acm.org/doi/10.1145/3016078.2851173 
> https://dl.acm.org/doi/10.1145/2688500.2688551
>

-- 
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/59c67911-1769-4f8b-8c95-1c6a70978dc6n%40googlegroups.com.


[go-nuts] $GOPATH/go.mod exists but should not

2021-01-10 Thread joseph.p...@gmail.com
I found (what I think is) a simple GO project to play with as a learning 
exercise:

  
 
https://intersog.com/blog/how-to-write-a-custom-url-shortener-using-golang-and-redis/

The second step fails immediately. with the aforementioned error message.

I'm using GO version 1.15.6
$GOPATH is undefined.
Here's the content of ~/go

Joes-iMac:go joe$ pwd

/Users/joe/go

Joes-iMac:go joe$ ls

bin go.mod pkg src

Joes-iMac:go joe$ more go.mod

module urlShorter


go 1.15

[eof]

So, I googled for the error message. I find lots of hits, but no clear 
explanation of why the error message, but most importantly, no clear 
explanation of how to fix...

Help please!

Thanks,

Joe

-- 
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/33438df6-65d0-4c6d-b905-b77a5d49c9e1n%40googlegroups.com.


[go-nuts] Packages vs methods

2023-04-03 Thread joseph.p...@gmail.com
When I’m reading go source and I see something like foo.bar(), my brain 
stutters for a second while I’m trying to determine if this is a reference 
to a package function or a receiver/method. Is there an easy way to make 
this determination?

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e33c9734-4d83-4e21-9a95-b23be5e5a9bcn%40googlegroups.com.


[go-nuts] Home directory?

2023-04-23 Thread joseph.p...@gmail.com
In the ‘Create a Go Module’ documentation, it keeps referencing ‘home 
directory’ and uses the unix command ‘cd’.

Do they literally mean my unix home directory or do they mean my GOPATH 
directory?

Have GOPATH and GOROOT been deprecated?

Thanks,

Hoe

-- 
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/adf24fcc-3530-4e7c-8e74-b48f3b54933cn%40googlegroups.com.


[go-nuts] Go modules question

2023-08-16 Thread joseph.p...@gmail.com
I’m reading a GO book for beginners.  They’re always naming their module in 
the form:
  github.com/username/program

Is the ‘github.com’ portion of the module name mandatory? I really have no 
intention of saving my code to github. If i’m saving my code locally, can i 
use an arbitrary module name?

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/8055599f-949e-4eab-8ec2-116be3715099n%40googlegroups.com.


[go-nuts] templates not working for me

2024-02-03 Thread joseph.p...@gmail.com
I'm goofing around with GIN and trying some examples. I can't get 
templating to work for me.

File inclusion works, but variable substitution does not.

GOLANG version 1.20.12

package main


import "github.com/gin-gonic/gin"

import "net/http"

// import "gorm.io/driver/sqlite"

// import "gorm.io/gorm"


func main() {


server := gin.Default()


server.Static("/stylesheets", "./")


server.LoadHTMLGlob("templates/*.html")


server.GET("/test", func(ctx *gin.Context) {

ctx.JSON(200, gin.H{

"message": "OK!!",

})

})

server.GET("/temp", func(ctx *gin.Context) {

ctx.HTML(http.StatusOK, "index.html", gin.H{

"title": "Main website",

"foo": "bar",

})

})

server.GET("/index", func(ctx *gin.Context) {

ctx.JSON(200, gin.H{

"message": "OK!!",

})

})

server.Run(":8080")

}

Specifically, opening a browser and accessing the /temp endpoint doesn't 
change the title or print the text of 'foo'

templates/header.html:



   {{.title}}

  

   https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"; 
rel="stylesheet" 
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
 
crossorigin="anonymous">

 


 



What's going on here?


-- 
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/6f292267-c78f-44b8-a020-d73fb5ce64e2n%40googlegroups.com.


[go-nuts] Re: templates not working for me

2024-02-07 Thread joseph.p...@gmail.com
Ok,

Variable substitution doesn't seem to work in an included template file. Is 
that a known limitation?

On Saturday, February 3, 2024 at 11:40:40 PM UTC-8 joseph.p...@gmail.com 
wrote:

> I'm goofing around with GIN and trying some examples. I can't get 
> templating to work for me.
>
> File inclusion works, but variable substitution does not.
>
> GOLANG version 1.20.12
>
> package main
>
>
> import "github.com/gin-gonic/gin"
>
> import "net/http"
>
> // import "gorm.io/driver/sqlite"
>
> // import "gorm.io/gorm"
>
>
> func main() {
>
>
> server := gin.Default()
>
>
> server.Static("/stylesheets", "./")
>
>
> server.LoadHTMLGlob("templates/*.html")
>
>
> server.GET("/test", func(ctx *gin.Context) {
>
> ctx.JSON(200, gin.H{
>
> "message": "OK!!",
>
> })
>
> })
>
> server.GET("/temp", func(ctx *gin.Context) {
>
> ctx.HTML(http.StatusOK, "index.html", gin.H{
>
> "title": "Main website",
>
> "foo": "bar",
>
> })
>
> })
>
> server.GET("/index", func(ctx *gin.Context) {
>
> ctx.JSON(200, gin.H{
>
> "message": "OK!!",
>
> })
>
> })
>
> server.Run(":8080")
>
> }
>
> Specifically, opening a browser and accessing the /temp endpoint doesn't 
> change the title or print the text of 'foo'
>
> templates/header.html:
>
> 
>
>{{.title}}
>
>   
>
>https://cdn.jsdelivr.net/npm/boot...@5.3.2/dist/css/bootstrap.min.css 
> <https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css>" 
> rel="stylesheet" 
> integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
>  
> crossorigin="anonymous">
>
>  
>
>
>  
>
>
>
> What's going on here?
>
>
>

-- 
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/897d8172-07e2-42f5-a06d-57885d41fc16n%40googlegroups.com.