Re: [go-nuts] How to Create Dynamically Linked Go Programs Redux

2023-08-12 Thread jlfo...@berkeley.edu
permission to /usr/local/go? Then there's also the question of why building a Go program should write to /usr/local/go/pkg/linux_amd64_dynlink. Jon On Saturday, August 12, 2023 at 1:01:22 PM UTC-7 Ian Lance Taylor wrote: > On Sat, Aug 12, 2023 at 10:27 AM jlfo...@berkeley.edu > wrote: > >

Re: [go-nuts] How to Create Dynamically Linked Go Programs Redux

2023-08-12 Thread jlfo...@berkeley.edu
suggest you add this to your test suite. Cordially, Jon Forrest On Friday, August 11, 2023 at 10:00:12 PM UTC-7 Ian Lance Taylor wrote: > On Fri, Aug 11, 2023 at 6:15 PM jlfo...@berkeley.edu > wrote: > > > > Now that Go 1.21 has been released, I've returned to trying to

[go-nuts] How to Create Dynamically Linked Go Programs Redux

2023-08-11 Thread jlfo...@berkeley.edu
Now that Go 1.21 has been released, I've returned to trying to figure out how to dynamically link a Go program. Back in January I posted the results of my first attempt with an earlier version of Go, which was: 1) Building a Go shared library by running go install -buildmode=shared

[go-nuts] Short Variable Declarations Are Oversold

2023-04-22 Thread jlfo...@berkeley.edu
As a beginning Go programmer, I was initially attracted to the short variable declaration syntax. It’s great for declaring variables of a simple type. What could be wrong with letting the Go compiler infer a variable type by looking at what’s being assigned to the variable, such as: func

Re: [go-nuts] Confusing Time Issue

2023-04-21 Thread jlfo...@berkeley.edu
You're absolutely right, of course. Jon -- 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

[go-nuts] Confusing Time Issue

2023-04-21 Thread jlfo...@berkeley.edu
Consider the program below. I want to compute the duration between a time that I put in the "old_time_str" variable and the current time. If I put the current time in a string, the program shows the correct duration. If I get the current time using time.Now() then the duration shown is 7 hours

[go-nuts] Minor Omission in List on https://pkg.go.dev/golang.org/x

2023-03-10 Thread jlfo...@berkeley.edu
Shouldn't "term" be included in the list shown on https://pkg.go.dev/golang.org/x? Going directly to https://pkg.go.dev/golang.org/x/term appears to work fine. Jon -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group

Re: [go-nuts] please continue High Sierra mac OSX support

2023-02-03 Thread jlfo...@berkeley.edu
I have a Mid 2013 Macbook Pro that stopped being supported by MacOS several releases ago. I heard about OpenCore, which magically patches the installer for the current release of MacOS to run on older hardware. To my utter amazement, it works! I'm now running the latest version of MacOS

Re: [go-nuts] Creating and Linking to Shared Library Version of Go Runtime? (with possible solution)

2023-02-03 Thread jlfo...@berkeley.edu
Good idea. FYI - this is on a Fedora 37 6.1.8-200.fc37.x86_64 server with go version go1.20 linux/amd64. I'm running a VM in Virtualbox with snapshots so it's very easy to go back to an unmodified system after running an experiment. Note that I'm adding the '-a' option to the go build commands

Re: [go-nuts] Creating and Linking to Shared Library Version of Go Runtime? (with possible solution)

2023-01-31 Thread jlfo...@berkeley.edu
I agree with you 100%. The 'go install' step that creates the shared runtime library should only be done by root. On the other hand, there's no reason I can see for the 'go build' step to write anything at all into /usr/local/go. But that's clearly happening. That's one of the causes of this

Re: [go-nuts] Creating and Linking to Shared Library Version of Go Runtime? (with possible solution)

2023-01-30 Thread jlfo...@berkeley.edu
Thanks for the comments. I had to do it as root because running go install -buildmode=shared std as me results in go install internal/goarch: mkdir /usr/local/go/pkg/linux_amd64_dynlink: permission denied As root, changing the ownership of /usr/local/go/pkg/linux_amd64_dynlink to me, and

Re: [go-nuts] Creating and Linking to Shared Library Version of Go Runtime? (with possible solution)

2023-01-30 Thread jlfo...@berkeley.edu
I'm the original poster. I've looked into this more and I might have an explanation for what's going on. Just for yuks, I started with perhaps the simplest Go program, which I called t.go: package main func main() { } As root, I was able to build both a dynamically (21512 bytes) and a

Re: [go-nuts] Creating and Linking to Shared Library Version of Go Runtime?

2023-01-29 Thread jlfo...@berkeley.edu
The discussion of SSD wear and tear is going way off my original question. I'm sorry I even mentioned it. Can we drop it? I'm still interested in the answer to the original question, which we've made some progress in answering. As of now the answer is yes, subject to some permission and

Re: [go-nuts] Creating and Linking to Shared Library Version of Go Runtime?

2023-01-28 Thread jlfo...@berkeley.edu
UTC-8 Ian Lance Taylor wrote: > On Sat, Jan 28, 2023 at 11:27 AM jlfo...@berkeley.edu > wrote: > > > > For people like me who have no intention of ever distributing a Go > executable, I wonder > > if it would be useful, and possible, to link to a shared library version

[go-nuts] Creating and Linking to Shared Library Version of Go Runtime?

2023-01-28 Thread jlfo...@berkeley.edu
For people like me who have no intention of ever distributing a Go executable, I wonder if it would be useful, and possible, to link to a shared library version of the Go Runtime. This would make my binaries much smaller and would reduce ware and tear on my SSD. Of course, this presumes that

Re: [go-nuts] Re: Building a Package With Multiple Subdirectories?

2022-11-22 Thread jlfo...@berkeley.edu
lic dependencies rather than hack > the go compiler and make it do something it wasn't designed to do? > > Best regards, > Christian > > On Tue, Nov 22, 2022, 4:44 PM jlfo...@berkeley.edu > wrote: > >> The reason I'm asking this question is because, as a learning exerc

[go-nuts] Re: Building a Package With Multiple Subdirectories?

2022-11-22 Thread jlfo...@berkeley.edu
ackage files in a single directory. Or break them up into > multiple packages. > That is the way everyone else write Go. If you follow the convention, your > life will be simpler, > and your code will be easier for others to understand and maintain. > > > On Tuesday, 22 November 2022 at

[go-nuts] Building a Package With Multiple Subdirectories?

2022-11-21 Thread jlfo...@berkeley.edu
Back in June I asked why Go requires all the files in a package to be in the same directory. I learned that this is an implementation-specific decision. I was also referred to https://stackoverflow.com/questions/45899203/can-i-develop-a-go-package-in-multiple-source-directories which

Re: [go-nuts] Elementary Question About Calling Functions in Different Packages

2022-06-11 Thread jlfo...@berkeley.edu
On Friday, June 10, 2022 at 8:47:54 PM UTC-7 jlfo...@berkeley.edu wrote: > > One hack solution I came up with to break cycles when Package A depends on > Package B which depends on Package A is to > create a symbolic link in Package A to the file(s) in Package B that

Re: [go-nuts] Elementary Question About Calling Functions in Different Packages

2022-06-10 Thread jlfo...@berkeley.edu
On Friday, June 10, 2022 at 6:48:58 PM UTC-7 ben...@gmail.com wrote: > > I agree it might be painful, and might lead to non-idiomatic Go! But it > sounds like a really good challenge, and will no doubt teach you a lot > along the way. It looks like you've already learned something from this

Re: [go-nuts] Elementary Question About Calling Functions in Different Packages

2022-06-09 Thread jlfo...@berkeley.edu
Thanks for the quick inciteful response. > From https://go.dev/ref/spec#Import_declarations: > > > It is illegal for a package to import itself, directly or indirectly, > or to directly import a package without referring to any of its exported > identifiers. > > I should have researched

[go-nuts] Elementary Question About Calling Functions in Different Packages

2022-06-09 Thread jlfo...@berkeley.edu
I'm having trouble understanding what should be a trivial issue. I have the following file structure: . ├── go.mod ├── main.go ├── p1 │ └── p1.go └── p2 └── p2.go The files are small and simple. -- go.mod module wp go 1.18 -- main.go // main.go package main import ( "wp/p1"

[go-nuts] Packages for Accessing .a Archives?

2022-04-09 Thread jlfo...@berkeley.edu
Other than what's in the Go distribution, I haven't been able to find any packages for accessing .a archives. Is there anything else out there? Google wasn't helpful. Cordially, Jon Forrest -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] How Does This Work?

2022-03-06 Thread jlfo...@berkeley.edu
ile you can't refer to a private type like os.fileStat there > is nothing prohibiting the os package from returning a private type that > satisfies an interface. See, for example, > https://github.com/golang/go/blob/45f45444b307cea7c8330b100b30382e642e010f/src/os/stat_unix.go#L15-L26

[go-nuts] How Does This Work?

2022-03-06 Thread jlfo...@berkeley.edu
(go version go1.17.7 linux/amd64) Consider the following trivial program: -- package main import ( "fmt" "os" ) func main() { file := "." fileinfo, _ := os.Stat(file) fmt.Printf("type of fileinfo = %T\n", fileinfo) } -- This runs and produces the

Re: [go-nuts] Data Structure for String Interning?

2022-01-09 Thread jlfo...@berkeley.edu
On Sunday, January 9, 2022 at 3:07:18 PM UTC-8 bse...@computer.org wrote: > Note that a with a map[string]string, the code: > > m[s]=s > > The contents of the string s are not duplicated, only the string header s > is. > I didn't know this. That's very good to know. What about this:

[go-nuts] Data Structure for String Interning?

2022-01-09 Thread jlfo...@berkeley.edu
I'm aware of Artem Krylysov's idea for string interning published on https://artem.krylysov.com/blog/2018/12/12/string-interning-in-go/ If I understand it correctly, each string is stored twice in a map, once as a key and once as a value. That means that words that only appear once in his example

Re: [go-nuts] Two Questions About Maps

2021-12-19 Thread jlfo...@berkeley.edu
On Sunday, December 19, 2021 at 9:24:00 AM UTC-8 Jan Mercl wrote: > On Sun, Dec 19, 2021 at 6:03 PM jlfo...@berkeley.edu > wrote: > > 1) Let's say I wanted to make the map elements smaller, so the map value > would be a pointer to a structure, not the structure itself. I cou

[go-nuts] Two Questions About Maps

2021-12-19 Thread jlfo...@berkeley.edu
Consider the following extremely condensed program: package main type func_type func (a string)(out int) type fte struct { name string expand_args bool function func_type } var ft = map[string]fte { "a":{"a", true, func_a}, }; func func_a(a

[go-nuts] Does Location of Variable Declarations Matter?

2021-11-28 Thread jlfo...@berkeley.edu
Some people put all their variable declarations at the beginning of a function. Others put them at various places in a function, where the variables are used. I've always wondered if a variable declaration results in any runtime overhead. One obvious concern is what happens if a variable

Re: [go-nuts] HPC image processing in go?

2021-11-04 Thread jlfo...@berkeley.edu
I'm wondering if it would be worth the effort to improve Go's vectorization optimizations as opposed to creating/improving its bindings to the various GPUs. Jon On Thursday, November 4, 2021 at 7:28:15 AM UTC-7 david@gmail.com wrote: > On Thu, Nov 4, 2021 at 5:43 AM quin...@gmail.com >

Re: [go-nuts] Does, or Will, Go Support Initialized .data Segments?

2021-10-27 Thread jlfo...@berkeley.edu
You're right, of course. Thanks. So is it true that package level initializations (that are used) require no runtime, other than some loader time to set up? Jon On Wednesday, October 27, 2021 at 3:54:08 PM UTC-7 Ian Lance Taylor wrote: > On Wed, Oct 27, 2021 at 3:34 PM jlfo...@berkeley.

Re: [go-nuts] Does, or Will, Go Support Initialized .data Segments?

2021-10-27 Thread jlfo...@berkeley.edu
Wednesday, October 27, 2021 at 11:58:11 AM UTC-7 Kurtis Rader wrote: > On Wed, Oct 27, 2021 at 10:49 AM jlfo...@berkeley.edu < > jlfo...@berkeley.edu> wrote: > >> I've noticed that Go doesn't seem to support the intialized .data segment >> that I used to find on Unix. Is t

[go-nuts] Does, or Will, Go Support Initialized .data Segments?

2021-10-27 Thread jlfo...@berkeley.edu
I've noticed that Go doesn't seem to support the intialized .data segment that I used to find on Unix. Is this correct? I've tried using various Go tools to find out but I'm not sure what I was seeing. If it isn't supported now, is this something planned for the future? Cordially, Jon Forrest

Re: [go-nuts] Re: Why Doesn't "len()" Work With Structs?

2021-10-24 Thread jlfo...@berkeley.edu
gt; https://play.golang.org/p/f0x8p_04lP1 ;) > > > On Sun, 2021-10-24 at 16:44 -0700, jlfo...@berkeley.edu wrote: > > Thanks for the replies. > > > > I had been trying to translate the trick from C into Go where you can > > find how many structures are in an initi

[go-nuts] Re: Why Doesn't "len()" Work With Structs?

2021-10-24 Thread jlfo...@berkeley.edu
the sum of its members' lengths) would require > recursive calls, and almost surely infinite cycles as we eventually get to > pointers. > > On Sunday, October 24, 2021 at 8:11:37 PM UTC+2 jlfo...@berkeley.edu > wrote: > >> I noticed that the len() function doesn't take a struct as an

[go-nuts] Why Doesn't "len()" Work With Structs?

2021-10-24 Thread jlfo...@berkeley.edu
I noticed that the len() function doesn't take a struct as an argument (see below). This is a big surprise. Can someone shed some light on why this restriction exists? Cordially, Jon Forrest -- package main import "fmt" var s struct { i1 int i2 int } func

[go-nuts] GNU getopt-style Go packages?

2021-09-04 Thread jlfo...@berkeley.edu
I'm wondering what the current state of GNU getopt-style Go packages is. I've done some research and found the following: DavidGamba / go-getoptions alecthomas / kong elegos / flags jessevdk / go-flags pborman / getopt pborman / options skeeto / optparse-go spf13 / cobra subchen / go-cli tcler /

[go-nuts] Makefiles for Go Programs

2021-08-22 Thread jlfo...@berkeley.edu
I've noticed that few, if any, Go programs use Makefiles. Is that because the overhead of using make is greater than the overhead of just always compiling and linking everything? One piece of evidence for this is that the Go compiler leaves no artifacts, like object files, so as is make

[go-nuts] Unexpected Issue Debugging Go From VSCode

2020-09-25 Thread jlfo...@berkeley.edu
windows 10 x86_64 go version go1.15.1 windows/amd64 vscode 1.49.2 vscode go extension 0.17.0 I learned something disappointing about debugging Go from VS Code. Consider the following trivial program extracted from a larger program: package main var gvar int func main() { var lvar int