[go-nuts] Re: Go 1.17.1 runtime seems retain too much memory from OS

2022-11-23 Thread 'Zhao Weng' via golang-nuts
sorry for being not specific.

my question is:

according to my understanding about memstat ( correct me if I'm wrong)

with GOGC set to 50, I can see from the graph above that GCGoal is ~ 26GB
and heapIdle - heapReleased is how much memory go runtime retain from OS 
for later usage, how can it (heapIdle - heapReleased) be 35GB which is 1.3x 
GCGoal ? 

it seem to me is something stop scavenger from releasing those memory back 
to OS.

and by reading the code:

// HeapIdle is bytes in idle (unused) spans.
//
// Idle spans have no objects in them. These spans could be
// (and may already have been) returned to the OS, or they can
// be reused for heap allocations, or they can be reused as
// stack memory.
//
// HeapIdle minus HeapReleased estimates the amount of memory
// that could be returned to the OS, but is being retained by
// the runtime so it can grow the heap without requesting more
// memory from the OS. If this difference is significantly
// larger than the heap size, it indicates there was a recent
// transient spike in live heap size.
HeapIdle uint64

and from mgcscavenge.go:

// That goal is defined as:
// (retainExtraPercent+100) / 100 * (heapGoal / lastHeapGoal) * 
last_heap_inuse

it seems (heapIdle - heapReleased) should be like 3GB (which is 
retainExtraPercent/100 * heapInUse ~ 10% * 26GB ~ 3GB)

and i'm really confused by this situation that (heapIdle - heapReleased) be 
35GB
On Thursday, November 24, 2022 at 3:09:10 PM UTC+8 Amnon wrote:

> Have a look at https://tip.golang.org/doc/gc-guide
>
> and 
> https://opensourcelive.withgoogle.com/events/go-day-2022/watch?talk=talk4
>
> On Thursday, 24 November 2022 at 05:08:55 UTC Zhao Weng wrote:
>
>> [image: memory.jpg]
>> memstats show heapIdle - heapReleased > heapAlloc or heapInUse
>>
>> I try to search the code and found the below comment:
>>
>> // HeapIdle is bytes in idle (unused) spans.
>> //
>> // Idle spans have no objects in them. These spans could be
>> // (and may already have been) returned to the OS, or they can
>> // be reused for heap allocations, or they can be reused as
>> // stack memory.
>> //
>> // HeapIdle minus HeapReleased estimates the amount of memory
>> // that could be returned to the OS, but is being retained by
>> // the runtime so it can grow the heap without requesting more
>> // memory from the OS. If this difference is significantly
>> // larger than the heap size, it indicates there was a recent
>> // transient spike in live heap size.
>> HeapIdle uint64
>>
>> and from mgcscavenge.go:
>>
>> // That goal is defined as: 
>> // (retainExtraPercent+100) / 100 * (heapGoal / lastHeapGoal) * 
>> last_heap_inuse
>>
>> it seem to me heapIdle - heapReleased should be ~ heapInUse * 10%
>>
>> can anybody help me understand this?
>>
>> many 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/08146e99-5ea8-49ed-9a65-4b04c362f4d3n%40googlegroups.com.


[go-nuts] Re: Go 1.17.1 runtime seems retain too much memory from OS

2022-11-23 Thread Amnon
Have a look at https://tip.golang.org/doc/gc-guide

and 
https://opensourcelive.withgoogle.com/events/go-day-2022/watch?talk=talk4

On Thursday, 24 November 2022 at 05:08:55 UTC Zhao Weng wrote:

> [image: memory.jpg]
> memstats show heapIdle - heapReleased > heapAlloc or heapInUse
>
> I try to search the code and found the below comment:
>
> // HeapIdle is bytes in idle (unused) spans.
> //
> // Idle spans have no objects in them. These spans could be
> // (and may already have been) returned to the OS, or they can
> // be reused for heap allocations, or they can be reused as
> // stack memory.
> //
> // HeapIdle minus HeapReleased estimates the amount of memory
> // that could be returned to the OS, but is being retained by
> // the runtime so it can grow the heap without requesting more
> // memory from the OS. If this difference is significantly
> // larger than the heap size, it indicates there was a recent
> // transient spike in live heap size.
> HeapIdle uint64
>
> and from mgcscavenge.go:
>
> // That goal is defined as: 
> // (retainExtraPercent+100) / 100 * (heapGoal / lastHeapGoal) * 
> last_heap_inuse
>
> it seem to me heapIdle - heapReleased should be ~ heapInUse * 10%
>
> can anybody help me understand this?
>
> many 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/b63e9b4b-efb4-4209-aaf1-fb4783b41fbdn%40googlegroups.com.


Re: [go-nuts] Problems with array slicing reliability?

2022-11-23 Thread Amnon
As others have said, it is worth trying to reduce the program to the 
minimal version which reproduces your problem
(and then publishing it on https://go.dev/play/ ).


On Thursday, 24 November 2022 at 02:38:30 UTC kra...@skepticism.us wrote:

> You cannot mutate strings. Your code is also missing a final close-brace 
> and possibly has other problems. That your example includes commented out 
> code is also problematic. As Nikhilesh Susarla pointed out you should post 
> a link to the Go playground to avoid any ambiguity.
>
> I added the missing close-brace to your code and observed the following 
> behavior (I entered "1" at the prompt):
>
> > go run x.go 
>  144.6 ms
> State where the hash counter should begin:>> 1
> panic: runtime error: invalid memory address or nil pointer dereference
> [signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x102536674]
>
> This tells me there is a fundamental bug in your code having nothing to do 
> with "Problems with array slicing reliability"
>
> On Wed, Nov 23, 2022 at 1:56 PM Mucas Schlack  wrote:
>
>> Hello Golangers!
>> Is there anyone who can test the reliability of the following Golang 
>> slice feature? I am using an AMG64 computer with Windows 10, and Go version 
>> 0.36.0. When I use the following code, to detect and then replace a 
>> character at any given length *n* (9) in a string with an Uppercase 
>> Character. Strangely and somehow, the slice pointer will move to another 
>> position even though the code is not dynamic and has not changed. Is there 
>> anyone who can trouble shoot this code for me?
>>
>> Please remember that this is "*test*" code only, so some of it will not 
>> make any sense or work. It is only "proof of concept" code.
>>
>> The code to pay attention to is the following - from lines: 80 - 92!
>>
>> Many thanks for any help you can give!
>>
>> Mucas
>>
>> Example code:
>>
>> package main
>>
>> import(
>> //"unicode/utf8"
>> "math/rand"
>> "strconv"
>> "strings"
>> "fmt"
>> "time"
>> "os"
>> )
>>
>> var alphanumerics = [62] string {
>> 
>> "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
>> "0","1","2","3","4","5","6","7","8","9",
>> 
>> "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
>> }
>>
>> func main(){
>>
>> var (
>> txtflpth string = "C:\\Workspace\\Transaction Hash.txt"
>> flNm string = "Transaction Hash.txt"
>> CRLF string = "\n"
>> cntstrt string
>> AuthKey string
>> NwStr string
>> cstart int
>> cntr int
>> flEx *os.FileInfo
>> flEx2 *os.File
>> trfl *os.File
>> err error
>> ) 
>>
>> fmt.Print("State where the hash counter should begin:>> ")
>> fmt.Scanln()
>>
>> if cntstrt == "" || cntstrt == " " { 
>> trfl, err = os.Create(flNm)
>> 
>> if err != nil { panic(err); os.Exit(-1) }
>> defer trfl.Close() 
>>
>> } else {
>> var flEx, err = os.Stat(txtflpth)
>> 
>> fmt.Println(flEx.Mode().String)
>> //fmt.Println(flEx.IsRegular())
>> fmt.Println(flEx.IsDir())
>> fmt.Println(flEx.Name())
>> fmt.Println(flEx.Size())
>> fmt.Println(flEx.Sys())
>>
>> if err != nil { if os.IsNotExist(err) { panic(err) } }
>> 
>> cstart, err = strconv.Atoi(cntstrt)
>> flEx2, err := os.Open(txtflpth)
>> defer flEx2.Close() 
>> }
>>
>> /*defer func(
>> if err == trfl.Close() || err == os.IsNotExist(err)!= err { 
>> panic(err) }
>> if err == flEx.Close() || err == os.IsNotExist(err)!= err { 
>> panic(err) }
>> )*/
>>
>> if cntstrt != "" && cntstrt != " " { cntr = cstart }
>>
>> for cntr = cstart; cntr < cstart + 1000; cntr++ {
>> NwStr = ""
>> AuthKey = NwStr
>>
>> for i := 0; i <= 65; i++ {
>> time.Sleep(10 * time.Nanosecond)
>> rand.Seed(time.Now().UnixNano()) 
>> AuthKey = AuthKey + alphanumerics[rand.Intn(62)] //, [A - Z], 
>> [0-9])
>> }
>>
>> var hashRemap = [...] string {"A","U","G","D","E","X"}
>> 
>> AuthKey = "0x" + AuthKey
>> fmt.Println("Transaction Hash: " + strconv.Itoa(cntr) + ") " + 
>> AuthKey)
>> //AuthKey2 := []rune(AuthKey)
>>
>> StrPos := strings.Index(AuthKey, AuthKey[9:10])
>> fmt.Printf("The old character %s is at string position: (%d) " + 
>> CRLF,AuthKey[9:10], StrPos)
>> //os.Exit(1)
>>
>> for i := 0; i < 6; i++ {
>> switch i {
>> case 0: AuthKey = strings.Replace(AuthKey,AuthKey[9:10], 
>> hashRemap[0], 1); fmt.Println("Replaced! The New Transaction Hash: " + "(" 
>> + strconv.Itoa(i) + ") " + AuthKey); os.Exit(1);
>> case 1: AuthKey = 

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread robert engels
Your reading comprehension skills need some work.

The point of “labels matter” was answering Rob Pike’s “why does it matter” 
question.

I used extremely different objects - yet both modes of transportation - 
intentionally to highlight the need for common definitions in order to 
communicate.

The car & boat are very easy to differentiate because it is commonly understood 
what traits each of those labels imply.

If you change the objects to Go and Java and ask which languages are OO you get 
different opinions. If an OO programmer expects an OO language to have 
inheritance and late binding, it won’t be Go. Similarly, if I go to buy a car 
and someone tries to sell me a boat with the understanding I was simply looking 
for a mode of transportation  it won’t fly.

I think the fact that you immediately jump to insulting language says more 
about your state. Maybe you need a break. Or at least a lesson in manners.


> On Nov 23, 2022, at 11:07 PM, Holloway Kean Ho  
> wrote:
> 
> > I think the amount of hair-splitting over what is an object oriented 
> > language is reason to say it *isn't* an Object Oriented language at all.
> 
> Given the FAQ header's "Is Go an object-oriented language? emphasizing that 
> "object-oriented" is in lowercase, not the titlecase "Object-Oriented" that 
> generally points to OOP context: it is why I treat the FAQ "yes and no" as an 
> acceptable answer. 
> 
> My exhibits:
> Linux kernel is mainly based on C, but it managed to grouped its driver data 
> into an object-oriented way (various types of IO IP products) - See 
> (https://elixir.bootlin.com/linux/latest/source/drivers)
> Go's various standard packages like (url, strings, http, etc), they're 
> oriented to a specific data type. See URL package 
> (https://pkg.go.dev/net/url@go1.19.3#URL)
> Unlike C, Go and Rust has interface methods that behaves similar to an OOP 
> Class (see URL in #2).
> Therefore, you can't say they aren't OO but you certainly can say they 
> incompatible with the conventional OOP.
> 
> If an amendment is required, I believe the missing context (OO in plain 
> English or OO in OOP) has to be explictly clarified.  As far as definitions 
> goes, they are 2 different contexts. OOP is an implementation/subset of OO.
> 
> One thing for sure: I agreed that the mentioned FAQ header is a bit cheesy.
> 
> 
> 
> 
> >> Cars do not fly. Planes don’t use roads. Classes are abstractions that 
> >> model required attributes that in turn compose a system to do useful work. 
> >> Both boats and cars move. You can use a boat to get from a to b if there 
> >> is no water. 
> >> If someone said “I have a car for sale”, and you showed up and it had no 
> >> wheels but a hull and a sail - you might be a bit upset.
> >> Whether Go is a car or a boat is up to the experts.
> > Labels/common language is what allows societies to exist. As in this case, 
> > I believe your ESL has caused you to issue some statements above that make 
> > it difficult for people to understand what you are trying to say and may 
> > even interpret them to mean you are a rude person that should be ignored.
> > If you claim that labels are only useful when “it’s obvious what it is” - 
> > how do you determine it is obvious? Your personal experience/knowledge? An 
> > accepted “reference guide”?
> 
> If I re-phrase one of your example, it would be:
> 
> "I have a car (object) for sale" -> "Toyota Camry" (label) vs. "Tesla Model 
> S" (label) vs "AeroMobil 3.0" (label)
> They are all unilaterally labelled as "car". Can you say all 3 of them are 
> not object-oriented towards "car" definition? (OO)
> When and how should we specify a "car" across automobile and aeronautics 
> industries? Electric motors vs ICE engine? engine capable of flying + on the 
> road? defined, ratified, and enforced by who or whom? (OOP)
> I still don't see the examples ("car vs boat", "Acme1000 vs Beta1000") 
> relevancies. However, given the tone and the frames of those examples, I did 
> observed a known burnt-out pattern of a developer overworked for a long time 
> to the point where a "car" and a "boat" can no longer be cognitively 
> differentiable eventhough their clearly different in nature, unrelated to the 
> labelligng topic at all. This is a severe symptom and I called out the 
> psychological matter.
> 
> Given the recent mass layoffs, I'm not surpirsed some managers can pressure 
> the team to perform beyond limits. No ill intent. Sorry if you take it 
> another way.
> 
> Peace. Cheers!
> 
> 
> Regards,
> Holloway
> 
> -- 
> 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/730c3130-e4e9-4db5-87f6-589567f86fben%40googlegroups.com
>  
> 

[go-nuts] Please help me with structure data alignment

2022-11-23 Thread Maxim Velivanov
Hi,

I'm developing a Go wrapper for a dll.
dll contains the following structure:
struct ck_version {
  unsigned char major;
  unsigned char minor;
};

struct ck_info {
  struct ck_version cryptoki_version;
  unsigned char manufacturer_id[32];
  ck_flags_t flags;
  unsigned char library_description[32];
  struct ck_version library_version;
};

in Go there is its analogue:
type Ck_version struct {
Major uint8
Minor uint8
}

type Ck_info struct {
Cryptoki_versionCk_version
Manufacturer_id [32]byte
Flags   uint32
Library_description [32]byte
Library_version Ck_version
}

when i call the function
info := Ck_info{}
rv, _, _ := c_GetInfo.Call(uintptr(unsafe.Pointer()))

then I get the data offset starting from the flags field.

I understand that Go has different data alignment in structures than C 
compiler. But how then does a wrapper with tons of structures work in this 
project golang.org/x/sys/windows? Maybe I missed something?

-- 
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/20cc4c3b-b7fb-4c6b-b09d-333069d59d76n%40googlegroups.com.


Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread Holloway Kean Ho
> I think the amount of hair-splitting over what is an object oriented 
language is reason to say it *isn't* an Object Oriented language at all.

Given the FAQ header's "Is Go an object-oriented language? emphasizing that 
"object-oriented" is in lowercase, not the titlecase "Object-Oriented" that 
generally points to OOP context: it is why I treat the FAQ "yes and no" as 
an acceptable answer. 

My exhibits:

   1. Linux kernel is mainly based on C, but it managed to grouped its 
   driver data into an object-oriented way (various types of IO IP products) - 
   See (https://elixir.bootlin.com/linux/latest/source/drivers)
   2. Go's various standard packages like (url, strings, http, etc), 
   they're oriented to a specific data type. See URL package 
   (https://pkg.go.dev/net/url@go1.19.3#URL)
   3. Unlike C, Go and Rust has interface methods that behaves similar to 
   an OOP Class (see URL in #2).

Therefore, you can't say they aren't OO but you certainly can say they 
incompatible with the conventional OOP.

If an amendment is required, I believe the missing context (OO in plain 
English or OO in OOP) has to be explictly clarified.  As far as definitions 
goes, they are 2 different contexts. OOP is an implementation/subset of OO.

One thing for sure: I agreed that the mentioned FAQ header is a bit cheesy.




>> Cars do not fly. Planes don’t use roads. Classes are abstractions that 
model required attributes that in turn compose a system to do useful work. 
Both boats and cars move. You can use a boat to get from a to b if there is 
no water. 
>> If someone said “I have a car for sale”, and you showed up and it had no 
wheels but a hull and a sail - you might be a bit upset.
>> Whether Go is a car or a boat is up to the experts.
> Labels/common language is what allows societies to exist. As in this 
case, I believe your ESL has caused you to issue some statements above that 
make it difficult for people to understand what you are trying to say and 
may even interpret them to mean you are a rude person that should be 
ignored.
> If you claim that labels are only useful when “it’s obvious what it is” - 
how do you determine it is obvious? Your personal experience/knowledge? An 
accepted “reference guide”?

If I re-phrase one of your example, it would be:

"I have a car (object) for sale" -> "Toyota Camry" (label) vs. "Tesla Model 
S" (label) vs "AeroMobil 3.0" (label)

   1. They are all unilaterally labelled as "car". Can you say all 3 of 
   them are not object-oriented towards "car" definition? (OO)
   2. When and how should we specify a "car" across automobile and 
   aeronautics industries? Electric motors vs ICE engine? engine capable of 
   flying + on the road? defined, ratified, and enforced by who or whom? (OOP)

I still don't see the examples ("car vs boat", "Acme1000 vs Beta1000") 
relevancies. However, given the tone and the frames of those examples, I 
did observed a known burnt-out pattern of a developer overworked for a long 
time to the point where a "car" and a "boat" can no longer be cognitively 
differentiable eventhough their clearly different in nature, unrelated to 
the labelligng topic at all. This is a severe symptom and I called out the 
psychological matter.

Given the recent mass layoffs, I'm not surpirsed some managers can pressure 
the team to perform beyond limits. No ill intent. Sorry if you take it 
another way.

Peace. Cheers!


Regards,
Holloway

-- 
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/730c3130-e4e9-4db5-87f6-589567f86fben%40googlegroups.com.


Re: [go-nuts] Re: clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread Ayan George
Rob Pike  wrote:

> Let me ask, because I'm genuinely curious: Why does it matter? The labels
> we apply to things do not affect their function. Perhaps it affects how we
> think about them. Is that it?
>

Yes -- that's it exactly!

I think the amount of hair-splitting over what is an object oriented language
is reason to say it *isn't* an Object Oriented language at all.

This variety of definitions means Go will probably not meet anyone's
expectations.  It's useless to talk about it in terms of something that we
can't clearly define.

Practically, I think the phrase "Object Oriented" is almost synonymous with
Java and maybe C++ and C#.

If you kind of load that context in your mind as you read, it becomes:

Is Go an Object Oriented Language Like Java (or C++ or C#...)

Answering "yes" is almost permission to apply patterns from those languages to
Go as well.  And that's rarely a good fit.  We've all seen it: A Go code base
written with Java idioms or with C++ idioms, etc.

Saying "yes or no" is a non-answer. :)

Saying "yes" opens the possibility for people falsely attributing things to Go.

Saying "no" encourages people to abandon their pre-conceived notions and take
Go for what it is.

I recognize this is a kind of soft issue that is prone to bikeshedding.  I
considered it settled when Ian answered.

-ayan

-- 
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/637ee17a.rAmwWESC82r2zuxK%25ayan%40ayan.net.


[go-nuts] Re: cgo and Python as a shared library

2022-11-23 Thread Deiter
Doh! I forgot the include. I get a linker error now:
...
package main

/*
#cgo pkg-config: python3
#cgo LDFLAGS: -lpython3.8
#include 
*/
import "C"

import (
"fmt"
)

func main() {
C.Py_Initialize()
fmt.Println(C.GoString(C.Py_GetVersion()))
C.Py_Finalize()
}
...
$ go run .
# producer
/usr/local/go/pkg/tool/darwin_amd64/link: running clang failed: exit status 
1
ld: library not found for -lpython3.8
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)
...
Clearly a library is missing but I'm not clear where to find it or how to 
inform the linker. Thanks.

On Wednesday, November 23, 2022 at 6:48:25 PM UTC-8 Deiter wrote:

> macOS: 12.5.1
> go: go1.19.3 darwin/amd64
>
> I'm having trouble building a go module that uses Python as a shared 
> library.
>
> This code works:
> ...
> package main
>
> // #include 
> import "C"
> import "fmt"
>
> func main() {
> fmt.Println("Max float value of float is", C.FLT_MAX)
> }
> ...
> $ go run . 
> Max float value of float is 3.4028234663852886e+38
> ...
> I run into problems when I try to include Python:
> ...
> package main
>
> /*
> #cgo pkg-config: python3
> #cgo LDFLAGS: -lpython3.8
> */
> import "C"
>
> import (
> "fmt"
> )
>
> func main() {
> C.Py_Initialize()
> fmt.Println(C.GoString(C.Py_GetVersion()))
> C.Py_Finalize()
> }
> ...
> $ go run .
> # producer
> ./producer.go:16:2: could not determine kind of name for C.Py_Finalize
> ./producer.go:15:25: could not determine kind of name for C.Py_GetVersion
> ./producer.go:14:2: could not determine kind of name for C.Py_Initialize
> ...
>
> Any suggestions? I'm guessing it has something to do w/ setting 
> PKG_CONFIG_PATH and/or CGO_CFLAGS but I'm not certain...
>

-- 
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/d1b70059-0a25-4fbb-bcd9-9b133592cbe5n%40googlegroups.com.


Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread robert engels
I am not sure what you are trying to say here. 

> On Nov 23, 2022, at 8:36 PM, Holloway Kean Ho  
> wrote:
> 
> Your examples have something to do with the developer's psychological problem 
> for failing to distingush between objects; not OO, OOP, or any programming 
> languages. Neither Java or Go can rescue your situation. You should consider:
> Review his/her manager's work ethics for possible abusement.
> Get psychological help online for him/her.
> Communicate with your PM for porject's risk mitigation.
> Help him/her find a comaptible job.
> 


I will say it another way:

I am offering you a Acme1000 and a Beta1000 - both cost $100.  Which do you 
want?

Clearly you would ask: 1) Do I need either of these? 2) What is the difference 
between the two?

Labels/common language is what allows societies to exist. As in this case, I 
believe your ESL has caused you to issue some statements above that make it 
difficult for people to understand what you are trying to say and may even 
interpret them to mean you are a rude person that should be ignored.

Whether applying the OO label to Go makes sense depends on what you believe OO 
means. If you don’t have an accepted definition of a OO language, nor a 
complete understanding of Go itself - it is impossible to say that applying the 
label is correct or not. Ample evidence has been given that the definition of 
OO is “not universally accepted”.

If you claim that labels are only useful when “it’s obvious what it is” - how 
do you determine it is obvious? Your personal experience/knowledge? An accepted 
“reference guide”?

-- 
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/C1747791-6E80-462B-B089-28C992119237%40ix.netcom.com.


[go-nuts] cgo and Python as a shared library

2022-11-23 Thread Deiter
macOS: 12.5.1
go: go1.19.3 darwin/amd64

I'm having trouble building a go module that uses Python as a shared 
library.

This code works:
...
package main

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

func main() {
fmt.Println("Max float value of float is", C.FLT_MAX)
}
...
$ go run . 
Max float value of float is 3.4028234663852886e+38
...
I run into problems when I try to include Python:
...
package main

/*
#cgo pkg-config: python3
#cgo LDFLAGS: -lpython3.8
*/
import "C"

import (
"fmt"
)

func main() {
C.Py_Initialize()
fmt.Println(C.GoString(C.Py_GetVersion()))
C.Py_Finalize()
}
...
$ go run .
# producer
./producer.go:16:2: could not determine kind of name for C.Py_Finalize
./producer.go:15:25: could not determine kind of name for C.Py_GetVersion
./producer.go:14:2: could not determine kind of name for C.Py_Initialize
...

Any suggestions? I'm guessing it has something to do w/ setting 
PKG_CONFIG_PATH and/or CGO_CFLAGS but I'm not certain...

-- 
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/3143e01d-4143-49d5-b2e5-745ebec1406cn%40googlegroups.com.


Re: [go-nuts] Re: How to High-pass filter method for well height data

2022-11-23 Thread Harris, Andrew
 You might not need FFT for this problem, although it's a powerful tool that 
would work

The minimal LP/HP filter is very little code, 
https://ccrma.stanford.edu/~jos/filters/Definition_Simplest_Low_Pass.html



From: golang-nuts@googlegroups.com  on behalf of 
pat2...@gmail.com 
Sent: Wednesday, November 23, 2022 3:21:14 PM
To: golang-nuts 
Subject: [go-nuts] Re: How to High-pass filter method for well height data

You want to find a discrete fast fourier transform package.
convolve with a suitable filter, and then inverse the DFFT



--
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/281723e4-f401-4f4c-8c51-684c2f13914bn%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/CO2PR07MB25831BD5400A7DEBB594FDAAA00C9%40CO2PR07MB2583.namprd07.prod.outlook.com.


Re: [go-nuts] Problems with array slicing reliability?

2022-11-23 Thread Kurtis Rader
You cannot mutate strings. Your code is also missing a final close-brace
and possibly has other problems. That your example includes commented out
code is also problematic. As Nikhilesh Susarla pointed out you should post
a link to the Go playground to avoid any ambiguity.

I added the missing close-brace to your code and observed the following
behavior (I entered "1" at the prompt):

> go run x.go
 144.6 ms
State where the hash counter should begin:>> 1
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x102536674]

This tells me there is a fundamental bug in your code having nothing to do
with "Problems with array slicing reliability"

On Wed, Nov 23, 2022 at 1:56 PM Mucas Schlack  wrote:

> Hello Golangers!
> Is there anyone who can test the reliability of the following Golang slice
> feature? I am using an AMG64 computer with Windows 10, and Go version
> 0.36.0. When I use the following code, to detect and then replace a
> character at any given length *n* (9) in a string with an Uppercase
> Character. Strangely and somehow, the slice pointer will move to another
> position even though the code is not dynamic and has not changed. Is there
> anyone who can trouble shoot this code for me?
>
> Please remember that this is "*test*" code only, so some of it will not
> make any sense or work. It is only "proof of concept" code.
>
> The code to pay attention to is the following - from lines: 80 - 92!
>
> Many thanks for any help you can give!
>
> Mucas
>
> Example code:
>
> package main
>
> import(
> //"unicode/utf8"
> "math/rand"
> "strconv"
> "strings"
> "fmt"
> "time"
> "os"
> )
>
> var alphanumerics = [62] string {
>
> "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
> "0","1","2","3","4","5","6","7","8","9",
>
> "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
> }
>
> func main(){
>
> var (
> txtflpth string = "C:\\Workspace\\Transaction Hash.txt"
> flNm string = "Transaction Hash.txt"
> CRLF string = "\n"
> cntstrt string
> AuthKey string
> NwStr string
> cstart int
> cntr int
> flEx *os.FileInfo
> flEx2 *os.File
> trfl *os.File
> err error
> )
>
> fmt.Print("State where the hash counter should begin:>> ")
> fmt.Scanln()
>
> if cntstrt == "" || cntstrt == " " {
> trfl, err = os.Create(flNm)
>
> if err != nil { panic(err); os.Exit(-1) }
> defer trfl.Close()
>
> } else {
> var flEx, err = os.Stat(txtflpth)
>
> fmt.Println(flEx.Mode().String)
> //fmt.Println(flEx.IsRegular())
> fmt.Println(flEx.IsDir())
> fmt.Println(flEx.Name())
> fmt.Println(flEx.Size())
> fmt.Println(flEx.Sys())
>
> if err != nil { if os.IsNotExist(err) { panic(err) } }
>
> cstart, err = strconv.Atoi(cntstrt)
> flEx2, err := os.Open(txtflpth)
> defer flEx2.Close()
> }
>
> /*defer func(
> if err == trfl.Close() || err == os.IsNotExist(err)!= err {
> panic(err) }
> if err == flEx.Close() || err == os.IsNotExist(err)!= err {
> panic(err) }
> )*/
>
> if cntstrt != "" && cntstrt != " " { cntr = cstart }
>
> for cntr = cstart; cntr < cstart + 1000; cntr++ {
> NwStr = ""
> AuthKey = NwStr
>
> for i := 0; i <= 65; i++ {
> time.Sleep(10 * time.Nanosecond)
> rand.Seed(time.Now().UnixNano())
> AuthKey = AuthKey + alphanumerics[rand.Intn(62)] //, [A - Z],
> [0-9])
> }
>
> var hashRemap = [...] string {"A","U","G","D","E","X"}
>
> AuthKey = "0x" + AuthKey
> fmt.Println("Transaction Hash: " + strconv.Itoa(cntr) + ") " +
> AuthKey)
> //AuthKey2 := []rune(AuthKey)
>
> StrPos := strings.Index(AuthKey, AuthKey[9:10])
> fmt.Printf("The old character %s is at string position: (%d) " +
> CRLF,AuthKey[9:10], StrPos)
> //os.Exit(1)
>
> for i := 0; i < 6; i++ {
> switch i {
> case 0: AuthKey = strings.Replace(AuthKey,AuthKey[9:10],
> hashRemap[0], 1); fmt.Println("Replaced! The New Transaction Hash: " + "("
> + strconv.Itoa(i) + ") " + AuthKey); os.Exit(1);
> case 1: AuthKey = strings.Replace(AuthKey,"",
> hashRemap[1], 1)
> case 2: AuthKey = strings.Replace(AuthKey,"",
> hashRemap[3], 1)
> case 3: AuthKey = strings.Replace(AuthKey,"",
> hashRemap[4], 1)
> case 4: AuthKey = strings.Replace(AuthKey,"",
> hashRemap[5], 1)
> case 5: AuthKey = strings.Replace(AuthKey,"",
> hashRemap[5], 1)
> }
>
> }
>
> fmt.Println("Transaction Hash: " + strconv.Itoa(cntr) + ") " +
> AuthKey)
> if trfl != nil { 

Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread Holloway Kean Ho
> If the answer to that question is "yes and no," it'd be less ambiguous to 
simply say, "no."  And that would be a definitive way of indicating that it 
woul be inappropriate to apply many patterns from object oriented languages 
to Go -- and to encourage people to accept Go for what it is.
Go does facilitate data grouping towards a subject or an object. In fact, 
even C does that. By grouping your data and methods towards an object, you 
attained OO. Hence, that's the "yes" part. It's all down to your languages' 
mastery.

The "No" part is that Go, C, and even Rust are not honoring "polymorphism" 
where this contradicts 1/6 main traits of the OOP (thanks god but that's 
not a dare). Polymorphism had been a known problem for bloating and causing 
unwanted spaghettied data definitions all over the places AND confuse basic 
programming paradigm like "bloating class vs when to use modules" case. 
These problems had been plaguing known languages like Ruby.

Since the "Car" object is mentioned, try updating "Car" definition after 
you defined 2000+ car derivatives and its sub-derivatives using 
polymorphism, deployed across the world. I'm pretty sure various depts will 
come after you (either by their incompetence in OOP or your update broke 
their derived definitions). Therefore, Go, C, Rust, and similar, as an 
improvement measure, all work towards OOP's compositions heavily.

Bottomline: it depends on how deep you understand OO paradigm and how far 
you mastered a programming language OR be blindly religious about OOP.

Site-note: fanatism never ends well anywhere in this world; it had been 
proven and tested by time.



> Cars do not fly. Planes don’t use roads. Classes are abstractions that 
model required attributes that in turn compose a system to do useful work. 
Both boats and cars move. You can use a boat to get from a to b if there is 
no water. 
> If someone said “I have a car for sale”, and you showed up and it had no 
wheels but a hull and a sail - you might be a bit upset.
> Whether Go is a car or a boat is up to the experts.
Your examples have something to do with the developer's psychological 
problem for failing to distingush between objects; not OO, OOP, or any 
programming languages. Neither Java or Go can rescue your situation. You 
should consider:

   1. Review his/her manager's work ethics for possible abusement.
   2. Get psychological help online for him/her.
   3. Communicate with your PM for porject's risk mitigation.
   4. Help him/her find a comaptible job.


Regards,
Holloway
On Thursday, November 24, 2022 at 9:44:54 AM UTC+8 ren...@ix.netcom.com 
wrote:

> Human beings survive by classifications and compartmentalizing. Applying a 
> label associates it with certain traits.
>
> If someone said “I have a car for sale”, and you showed up and it had no 
> wheels but a hull and a sail - you might be a bit upset.
>
> Whether Go is a car or a boat is up to the experts.
>
> On Nov 23, 2022, at 7:27 PM, Rob Pike  wrote:
>
> Let me ask, because I'm genuinely curious: Why does it matter? The labels 
> we apply to things do not affect their function. Perhaps it affects how we 
> think about them. Is that it?
>
> -rob
>
>
> -- 
> 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/CAOXNBZS1vuSVcuHHgybwQH6e39ZRFH1eZaBUw%3D6nUj5sbpij%3DA%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/8aaff17a-2462-46f4-8d01-9737234393c7n%40googlegroups.com.


[go-nuts] Re: Problems with array slicing reliability?

2022-11-23 Thread Nikhilesh Susarla
Before anyone takes a look, can you please place the code 
in https://go.dev/play/ and then share that link where the code compiles 
and if it works on the browser and you have specific settings for goarch 
and goos then gophers can take a look at it. 

Thank you

On Thursday, 24 November 2022 at 03:27:03 UTC+5:30 loji...@gmail.com wrote:

> Hello Golangers!
> Is there anyone who can test the reliability of the following Golang slice 
> feature? I am using an AMG64 computer with Windows 10, and Go version 
> 0.36.0. When I use the following code, to detect and then replace a 
> character at any given length *n* (9) in a string with an Uppercase 
> Character. Strangely and somehow, the slice pointer will move to another 
> position even though the code is not dynamic and has not changed. Is there 
> anyone who can trouble shoot this code for me?
>
> Please remember that this is "*test*" code only, so some of it will not 
> make any sense or work. It is only "proof of concept" code.
>
> The code to pay attention to is the following - from lines: 80 - 92!
>
> Many thanks for any help you can give!
>
> Mucas
>
> Example code:
>
> package main
>
> import(
> //"unicode/utf8"
> "math/rand"
> "strconv"
> "strings"
> "fmt"
> "time"
> "os"
> )
>
> var alphanumerics = [62] string {
> 
> "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
> "0","1","2","3","4","5","6","7","8","9",
> 
> "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
> }
>
> func main(){
>
> var (
> txtflpth string = "C:\\Workspace\\Transaction Hash.txt"
> flNm string = "Transaction Hash.txt"
> CRLF string = "\n"
> cntstrt string
> AuthKey string
> NwStr string
> cstart int
> cntr int
> flEx *os.FileInfo
> flEx2 *os.File
> trfl *os.File
> err error
> ) 
>
> fmt.Print("State where the hash counter should begin:>> ")
> fmt.Scanln()
>
> if cntstrt == "" || cntstrt == " " { 
> trfl, err = os.Create(flNm)
> 
> if err != nil { panic(err); os.Exit(-1) }
> defer trfl.Close() 
>
> } else {
> var flEx, err = os.Stat(txtflpth)
> 
> fmt.Println(flEx.Mode().String)
> //fmt.Println(flEx.IsRegular())
> fmt.Println(flEx.IsDir())
> fmt.Println(flEx.Name())
> fmt.Println(flEx.Size())
> fmt.Println(flEx.Sys())
>
> if err != nil { if os.IsNotExist(err) { panic(err) } }
> 
> cstart, err = strconv.Atoi(cntstrt)
> flEx2, err := os.Open(txtflpth)
> defer flEx2.Close() 
> }
>
> /*defer func(
> if err == trfl.Close() || err == os.IsNotExist(err)!= err { 
> panic(err) }
> if err == flEx.Close() || err == os.IsNotExist(err)!= err { 
> panic(err) }
> )*/
>
> if cntstrt != "" && cntstrt != " " { cntr = cstart }
>
> for cntr = cstart; cntr < cstart + 1000; cntr++ {
> NwStr = ""
> AuthKey = NwStr
>
> for i := 0; i <= 65; i++ {
> time.Sleep(10 * time.Nanosecond)
> rand.Seed(time.Now().UnixNano()) 
> AuthKey = AuthKey + alphanumerics[rand.Intn(62)] //, [A - Z], 
> [0-9])
> }
>
> var hashRemap = [...] string {"A","U","G","D","E","X"}
> 
> AuthKey = "0x" + AuthKey
> fmt.Println("Transaction Hash: " + strconv.Itoa(cntr) + ") " + 
> AuthKey)
> //AuthKey2 := []rune(AuthKey)
>
> StrPos := strings.Index(AuthKey, AuthKey[9:10])
> fmt.Printf("The old character %s is at string position: (%d) " + 
> CRLF,AuthKey[9:10], StrPos)
> //os.Exit(1)
>
> for i := 0; i < 6; i++ {
> switch i {
> case 0: AuthKey = strings.Replace(AuthKey,AuthKey[9:10], 
> hashRemap[0], 1); fmt.Println("Replaced! The New Transaction Hash: " + "(" 
> + strconv.Itoa(i) + ") " + AuthKey); os.Exit(1);
> case 1: AuthKey = strings.Replace(AuthKey,"", 
> hashRemap[1], 1)
> case 2: AuthKey = strings.Replace(AuthKey,"", 
> hashRemap[3], 1) 
> case 3: AuthKey = strings.Replace(AuthKey,"", 
> hashRemap[4], 1)
> case 4: AuthKey = strings.Replace(AuthKey,"", 
> hashRemap[5], 1)
> case 5: AuthKey = strings.Replace(AuthKey,"", 
> hashRemap[5], 1)
> }
> 
> }
>
> fmt.Println("Transaction Hash: " + strconv.Itoa(cntr) + ") " + 
> AuthKey)
> if trfl != nil { trfl.WriteString("Transaction Hash: " + 
> strconv.Itoa(cntr) + ") " + AuthKey + CRLF) }
> if flEx != nil { flEx2.WriteString("Transaction Hash: " + 
> strconv.Itoa(cntr) + ") " + AuthKey + CRLF) }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving 

Re: [go-nuts] cannot initialize 1 variables with 2 values

2022-11-23 Thread Kurtis Rader
Perhaps explicitly capture the error value? That is,

result, err := GetAsOr[MyObj](services.GetServiceOr())

Alternatively, if you don't care if there is an error replace "err" with
"_" to make that clear.

On Wed, Nov 23, 2022 at 4:34 PM Denis P  wrote:

> Hi guys,
>
> Does anyone know how to pass it properly and without adding extra lines of
> code?
>
> ```
> func GetAsOr[T any](t interface{}, e error) (T, error) {
> return t.(T), e
> }
>
> func (s ServiceProvider) GetServiceOr() (interface{}, error) {
>
> }
>
> result := GetAsOr[MyObj](services.GetServiceOr()) // Error: cannot
> initialize 1 variables with 2 values
> ```
>
> --
> 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/308dd860-a980-449d-a710-201f074e4358n%40googlegroups.com
> 
> .
>


-- 
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%3DD8emGL%3DCP1R3Ct5hX4%3DMZr7RENvC-s9HU94Vnf%2B_8nJOg%40mail.gmail.com.


Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread robert engels
Human beings survive by classifications and compartmentalizing. Applying a 
label associates it with certain traits.

If someone said “I have a car for sale”, and you showed up and it had no wheels 
but a hull and a sail - you might be a bit upset.

Whether Go is a car or a boat is up to the experts.

> On Nov 23, 2022, at 7:27 PM, Rob Pike  wrote:
> 
> Let me ask, because I'm genuinely curious: Why does it matter? The labels we 
> apply to things do not affect their function. Perhaps it affects how we think 
> about them. Is that it?
> 
> -rob
> 
> 
> -- 
> 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/CAOXNBZS1vuSVcuHHgybwQH6e39ZRFH1eZaBUw%3D6nUj5sbpij%3DA%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/9724EBE0-47F5-453B-BA1D-CF2745BFE01D%40ix.netcom.com.


Re: [go-nuts] where is GOROOT set?

2022-11-23 Thread Kurtis Rader
Show us the output of `which go`. I'm not convinced you're using a native
Linux Go compiler.

On Wed, Nov 23, 2022 at 5:31 PM pat2...@gmail.com 
wrote:

> Just in case my use of the "windows installer" for go and then using
> WSL/bash
>
>> was confusing assorted magic env variables, I uninstalled/deleted the
> Windows installed version
> then I downloaded the "linux" version, and did the usual "sudo tar "
> install
>
> Made no difference
> Get the same error message
>
> $ cat go.mod
> module github.com/pfarrell51/gows/treesort
>
> go 1.19
>
>
> $ go test .
> # github.com/pfarrell51/gows/treesort
> treesort_test.go:11:2: package treesort is not in GOROOT
> (/usr/local/go/src/treesort)
> FAILgithub.com/pfarrell51/gows/treesort [setup failed]
> FAIL
>
> --
> 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/337a21ff-6c06-440d-9aa9-89aa4a1d071an%40googlegroups.com
> 
> .
>


-- 
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%3DD96YsSy62C%2BtQZ6NQCv6uvAt56b5%2Bb%3Dn0D5qwYo2EJyww%40mail.gmail.com.


Re: [go-nuts] where is GOROOT set?

2022-11-23 Thread Kurtis Rader
In your reply to the request for `go env` output you say "For all of the
above I am using WSL (bash under Windows 11)". It looks like you're using
the native Windows Go toolchain from WSL. I would not expect that to work
and that is likely the reason you're having problems. You should install Go
for Linux in WSL and use that. Note that "bash under Windows" isn't an
accurate description of WSL (although, it is a widely used one). WSL is
really a way to run Linux side-by-side with Windows in a manner akin to
what you would get with a third-party tool like VMware and with sharing of
filesystems. Running a native Windows program from WSL might work but you
cannot assume that is true.

On Wed, Nov 23, 2022 at 4:40 PM pat2...@gmail.com 
wrote:

> On Wednesday, November 23, 2022 at 7:00:35 PM UTC-5 kra...XXX wrote:
>
>> On Windows Go is normally installed to C:\Program Files\Go. You should
>> not put your source code inside that directory. Put the source for your
>> projects somewhere else such as %HOME%/go.
>>
>
> My source files are not under "C:\Program Files\Go"
>
> They are under a separate directory:
> /home/pfarrell/whome/sandbox/gows/treesort
>
> The error message contains an invented path that does not exist
>
> $ go test .
> # github.com/pfarrell51/gows/treesort
> treesort_test.go:11:2: package treesort is not in GOROOT (C:\Program
> Files\Go\src\treesort)
> FAILgithub.com/pfarrell51/gows/treesort [setup failed]
>
>> --
> 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/e8814b02-d072-4272-a12b-4509d353666cn%40googlegroups.com
> 
> .
>


-- 
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%3DD9WqiNyEga-oJO1LKBeSq6nmEJf-scxxy77hmakgaXXJA%40mail.gmail.com.


Re: [go-nuts] where is GOROOT set?

2022-11-23 Thread pat2...@gmail.com
Just in case my use of the "windows installer" for go and then using 
WSL/bash

> was confusing assorted magic env variables, I uninstalled/deleted the 
Windows installed version
then I downloaded the "linux" version, and did the usual "sudo tar " install

Made no difference
Get the same error message 

$ cat go.mod
module github.com/pfarrell51/gows/treesort

go 1.19


$ go test .
# github.com/pfarrell51/gows/treesort
treesort_test.go:11:2: package treesort is not in GOROOT 
(/usr/local/go/src/treesort)
FAILgithub.com/pfarrell51/gows/treesort [setup failed]
FAIL

-- 
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/337a21ff-6c06-440d-9aa9-89aa4a1d071an%40googlegroups.com.


Re: [go-nuts] Re: clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread Rob Pike
Let me ask, because I'm genuinely curious: Why does it matter? The labels
we apply to things do not affect their function. Perhaps it affects how we
think about them. Is that it?

-rob

-- 
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/CAOXNBZS1vuSVcuHHgybwQH6e39ZRFH1eZaBUw%3D6nUj5sbpij%3DA%40mail.gmail.com.


Re: [go-nuts] Shellquote in stdlib

2022-11-23 Thread 'Christian Stewart' via golang-nuts
Hi Kurtis,

On Wed, Nov 23, 2022, 4:57 PM Kurtis Rader  wrote:

> On Wed, Nov 23, 2022 at 7:33 AM Christian Stewart 
> wrote:
>
>> This is what I'm trying to accomplish:
>>
>> Start delve (dlv) with os/exec passing a set of []string os.Args as
>> --build-flags
>>
>> Let's say I have this build arguments set: []string{"-gcflags", "-N -l"}
>>
>>  - How can I pass this to --build-flags in Delve? strings.Join(flags,
>> " ") is wrong.
>>
>
> Note that there are two levels of quoting involved in your example and a
> package that does "shell quoting" isn't going to handle this scenario
> correctly except for uninteresting trivial cases.
>

Please explain?


>  - How can I pass this to "go" with os/exec correctly? The quotes are
>> not put properly.
>>
>
> I'm not sure I understand that question. If you're asking how to run `go
> -gcflags="-N -l"` via a program written in Go the answer is to call os.exec
> with the literal string "-gcflags=-N -l" as an argument. Note that if you
> execute the `go` command directly, rather than indirectly via a shell, you
> don't need quotes around the "-N -l" portion of that string since a shell
> isn't parsing the command.
>

That doesn't work, from my tests

This is why you should avoid running external commands indirectly through a
> shell. Doing so greatly, and usually needlessly, complicates constructing
> the command to be run.
>
>
>> There are some cross-platform cases where the shell quoting is used,
>> and the general "quote something" mechanics are similar on Windows and
>> Linux.
>>
>
> Similar is not the same as identical. The rules for how quoted strings,
> and other punctuation, are handled differs enough that only trivial,
> uninteresting, cases are likely to work correctly on both platforms. Heck,
> even on UNIX like systems if the user has set their login shell to a
> non-POSIX shell (like Fish or Elvish) and your code uses the login shell
> rather than something like /bin/sh you will be in for a surprise. :-)
>

I'm not calling out to the shell, just passing args to another process that
expects them to be shell quoted.

Thanks,
Christian

-- 
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/CA%2Bh8R2o8k%2BwLq%3DYPBLsaCePYP9de1q%2BvRk267Rnnbn7xyU_X0w%40mail.gmail.com.


Re: [go-nuts] Shellquote in stdlib

2022-11-23 Thread Kurtis Rader
On Wed, Nov 23, 2022 at 7:33 AM Christian Stewart 
wrote:

> This is what I'm trying to accomplish:
>
> Start delve (dlv) with os/exec passing a set of []string os.Args as
> --build-flags
>
> Let's say I have this build arguments set: []string{"-gcflags", "-N -l"}
>
>  - How can I pass this to --build-flags in Delve? strings.Join(flags,
> " ") is wrong.
>

Note that there are two levels of quoting involved in your example and a
package that does "shell quoting" isn't going to handle this scenario
correctly except for uninteresting trivial cases.


>  - How can I pass this to "go" with os/exec correctly? The quotes are
> not put properly.
>

I'm not sure I understand that question. If you're asking how to run `go
-gcflags="-N -l"` via a program written in Go the answer is to call os.exec
with the literal string "-gcflags=-N -l" as an argument. Note that if you
execute the `go` command directly, rather than indirectly via a shell, you
don't need quotes around the "-N -l" portion of that string since a shell
isn't parsing the command. This is why you should avoid running external
commands indirectly through a shell. Doing so greatly, and usually
needlessly, complicates constructing the command to be run.


> There are some cross-platform cases where the shell quoting is used,
> and the general "quote something" mechanics are similar on Windows and
> Linux.
>

Similar is not the same as identical. The rules for how quoted strings, and
other punctuation, are handled differs enough that only trivial,
uninteresting, cases are likely to work correctly on both platforms. Heck,
even on UNIX like systems if the user has set their login shell to a
non-POSIX shell (like Fish or Elvish) and your code uses the login shell
rather than something like /bin/sh you will be in for a surprise. :-)

On Sun, Nov 6, 2022 at 9:11 PM Kurtis Rader  wrote:
> >
> > On Sun, Nov 6, 2022 at 8:48 PM 'Christian Stewart' via golang-nuts <
> golang-nuts@googlegroups.com> wrote:
> >>
> >> There have been several discussions about shellquote in go-nuts in the
> past:
> >>
> >> https://github.com/kballard/go-shellquote
> >> https://github.com/gonuts/go-shellquote
> >>
> >> I've found it necessary to use both Split and Join in some cases when
> working with exec.Command.
> >>
> >> This seems like the type of thing that ought to be part of the stdlib,
> has there been any consideration towards including it or a similar
> implementation?
> >>
> >> This is useful for processing os.Args especially in CLI or emulated
> shell environments.
> >
> >
> > No, IMHO, because such quoting is OS specific. For example, the quoting
> for UNIX and Windows in this context are different. Furthermore, given the
> vagaries of the POSIX shell standard I am skeptical that either of the
> projects you linked to correctly manipulates such strings in every case.
> >
> > It would help if you provided a concrete example of the problem you need
> help with.
> >
> > --
> > Kurtis Rader
> > Caretaker of the exceptional canines Junior and Hank
>


-- 
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-E2Ut1A-prNgmURATLz%3DS6771jvDW0Z8X3Y3xwKtUR1g%40mail.gmail.com.


Re: [go-nuts] where is GOROOT set?

2022-11-23 Thread pat2...@gmail.com
On Wednesday, November 23, 2022 at 7:00:35 PM UTC-5 kra...XXX wrote:

> On Windows Go is normally installed to C:\Program Files\Go. You should not 
> put your source code inside that directory. Put the source for your 
> projects somewhere else such as %HOME%/go.
>

My source files are not under "C:\Program Files\Go"

They are under a separate directory:
/home/pfarrell/whome/sandbox/gows/treesort

The error message contains an invented path that does not exist

$ go test .
# github.com/pfarrell51/gows/treesort
treesort_test.go:11:2: package treesort is not in GOROOT (C:\Program 
Files\Go\src\treesort)
FAILgithub.com/pfarrell51/gows/treesort [setup failed]

>

-- 
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/e8814b02-d072-4272-a12b-4509d353666cn%40googlegroups.com.


Re: [go-nuts] where is GOROOT set?

2022-11-23 Thread pat2...@gmail.com
On Wednesday, November 23, 2022 at 6:31:51 PM UTC-5 se... wrote:

> output of `go env` please
>


I am using WSL (bash under Windows 11)

Shell env:
 env
HOSTTYPE=x86_64
LESSCLOSE=/usr/bin/lesspipe %s %s
LANG=C.UTF-8
WSL_DISTRO_NAME=Ubuntu
USER=pfarrell
PWD=/home/pfarrell/whome/sandbox/gows/treesort
HOME=/home/pfarrell
_=/usr/bin/env
pfarrell@Alien15:~/whome/sandbox/gows/treesort$


treesort$ go env
treesort$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\pfarrell\AppData\Local\go-build
set GOENV=C:\Users\pfarrell\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\pfarrell\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\pfarrell\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\pfarrell\sandbox\gows\treesort\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments 
-Wl,--no-gc-sections -fmessage-length=0 
-fdebug-prefix-map=C:\Users\pfarrell\AppData\Local\Temp\go-build2617285960=/tmp/go-build
 
-gno-record-gcc-switches
pfarrell@Alien15:~/whome/sandbox/gows/treesort$

[its unclear how the "GOPATH" was set, as it is not set in the shell env.]


Please note, the current pwd is
$ pwd
/home/pfarrell/whome/sandbox/gows/treesort

There is no such directory as the error message is reporting:
" (C:\Program Files\Go\src\treesort)"

There is a file, where the go installation process put a bunch of source 
files, so there is
" (C:\Program Files\Go\src)"

/mnt/c/Program Files/Go/src$ ls
Make.dist   bufio  cmddebug go  internal   mime 
  reflect   strconv   time
README.vendor   buildall.bash  cmp.bash   embed go.mod  io net 
   regexpstrings   unicode
all.bashbuiltincompress   encoding  go.sum  logos   
  run.bash  sync  unsafe
all.bat bytes  container  errorshashmake.bash  path 
  run.bat   syscall   vendor
all.rc  clean.bash contextexpvarhtmlmake.bat   
plugin run.rctestdata
archive clean.bat  crypto flag  image   make.rc   
 race.bash  runtime   testing
bootstrap.bash  clean.rc   database   fmt   index   math   
race.bat   sort  text

For all of the above I am using WSL (bash under Windows 11)
Just for fun, I tried Windows Power Shell (which I never use)

'C:\Program Files\go\bin\go.exe' test .
# github.com/pfarrell51/gows/treesort
treesort_test.go:11:2: package treesort is not in GOROOT (C:\Program 
Files\go\src\treesort)
FAILgithub.com/pfarrell51/gows/treesort [setup failed]
FAIL

Thanks
Pat



















 


 

-- 
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/43b30510-6d78-4874-aec0-eeb2a92651e9n%40googlegroups.com.


[go-nuts] cannot initialize 1 variables with 2 values

2022-11-23 Thread Denis P
Hi guys,

Does anyone know how to pass it properly and without adding extra lines of 
code?

```
func GetAsOr[T any](t interface{}, e error) (T, error) {
return t.(T), e
}

func (s ServiceProvider) GetServiceOr() (interface{}, error) {
   
}

result := GetAsOr[MyObj](services.GetServiceOr()) // Error: cannot 
initialize 1 variables with 2 values
```

-- 
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/308dd860-a980-449d-a710-201f074e4358n%40googlegroups.com.


[go-nuts] Re: clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread Kamil Ziemian
"But I feel like programmers bringing their ideas from other less 
ambiguously object oriented languages like Java and C++ often have 
difficulty writing idiomatic Go."
I personally think that Java and C++ are less ambiguously OOP, only because 
we informally define OOP language as "language that is similar enough to 
C++ or Java". But this is like defining car as being something that looks 
like Mercedes and then discussing problem "Is Toyota similar enough to 
Mercedes, to be called a car?".

We also should notice that Alan Kay, man that coined term OOP, said that in 
his opinion there are two languages that can be consider as OOP: Smalltalk 
and Lisp. Notable, he didn't think that C++ and Java counts as such.

I have no doubts that Java and C++ programmers would have a problem, at the 
beginning, with writing idiomatic Go. This is because, in my opinion and in 
much simplifies form, C++ is about gathering stuff, while Go is about 
adding behavior and abstracting from that on. To make you thing more clear, 
in C++ you gather all you data and functions in one entity that you call 
class. In Go, what you should do it to define some struct that gather data 
and after that you add methods that provide functionality for this data. 
Distinction between gathering and adding functionality, is probably more 
about feeling that how things working under the hood, but because we feel 
or don't feel a language, we can or can't write idiomatic code.

Going back to comparison, when you add enough functionality to some type in 
Go by writing methods, you can use interface to abstract from gathered 
data, to write code that care only about functionality. If we can do the 
same things with two different types, we don't care what data is inside of 
them. We don't care is square and circle have the same underlying data. If 
all we need to know is how to take their area and how to move them, we can 
ignore what is under the hood.

At this moment I cannot thing about good equivalent of Go interface in C++ 
(I don't know Java). I would guess that, maybe, it is closer to C++ 
template and far cry from inheritance. But this is a topic for another time.

I hope I didn't mess these things up.

Best regards,
Kamil
wtorek, 22 listopada 2022 o 16:05:25 UTC+1 ay...@ayan.net napisał(a):

>
> The Go FAQ begins the answer to the question, "Is Go an object-oriented 
> language," with, "yes and no."
>
>   https://go.dev/doc/faq#Is_Go_an_object-oriented_language
>
> The section goes on to say that Go has methods but there is no type 
> hierarchy.  I guess those are the yes and no.
>
> But I feel like programmers bringing their ideas from other less 
> ambiguously object oriented languages like Java and C++ often have 
> difficulty writing idiomatic Go.
>
> If the answer to that question is "yes and no," it'd be less ambiguous to 
> simply say, "no."  And that would be a definitive way of indicating that it 
> woul be inappropriate to apply many patterns from object oriented languages 
> to Go -- and to encourage people to accept Go for what it is.
>
> Since receivers are parameters and one could use methods without using the 
> method calling syntax at all, I'd suggest we'd classify it as a structured 
> programming language with methods.
>
> In either case, is there a way to make the FAQ more clear on this point?
>
> -ayan
>
>
>
>

-- 
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/dae9f6d6-d5f7-4242-9b14-4c95d42abdc9n%40googlegroups.com.


Re: [go-nuts] where is GOROOT set?

2022-11-23 Thread Kurtis Rader
On Windows Go is normally installed to C:\Program Files\Go. You should not
put your source code inside that directory. Put the source for your
projects somewhere else such as %HOME%/go.

On Wed, Nov 23, 2022 at 3:26 PM pat2...@gmail.com 
wrote:

> I've separated my code into separate subdirectories, added a go.mod
> ran go mod tidy on each.
>
> I'm mostly back where I started, which a better source file tree
>
> I'm trying to test the "treesort" package from the "Donovan and Kernigan"
> The Go programing language book.
>
> When I connect into the treesort subdirectory, you can see the files, but
> I get a bad GOROOT error trying to do a "go test ."
>
> treesort$ ls
> go.mod  treesort.go  treesort_test.go
>
>
> pfarrell@Alien15:~/whome/sandbox/gows/treesort$ cat go.mod
> module github.com/pfarrell51/gows/treesort
>
> go 1.19
>
> pfarrell@Alien15:~/whome/sandbox/gows/treesort$ go test .
> # github.com/pfarrell51/gows/treesort
> treesort_test.go:11:2: package treesort is not in GOROOT (C:\Program
> Files\Go\src\treesort)
> FAILgithub.com/pfarrell51/gows/treesort [setup failed]
> FAIL
>
> How can I get past this?
> Thanks
> Pat
>
> --
> 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/4b365c67-6f3d-4edc-97d5-dbe505604818n%40googlegroups.com
> 
> .
>


-- 
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%3DD9U5vGq7O%3DZdf_t8BugwnJQwPud2jWzYGw4q02dKZmU5A%40mail.gmail.com.


Re: [go-nuts] clarifying Go FAQ: Is Go an object-oriented language?

2022-11-23 Thread Kamil Ziemian
I think in the 1990s it was a debate if Lisp with Common List Object System 
(CLOS) is OOP language. The answer they arrive was something like that.
"No, if your definition of OOP is based on C++. But, why your definition of 
OOP should be based on C++?"

I think the same fits Go. Go is in many ways not a C++-like language, so if 
C++ is for someone golden standard of property X, then Go probably doesn't 
have X.

For these reasons I don't like question is language X is OOP? What matters 
for X = Go for me is that it provides you power to create new data types 
and abstractions that allow you to write reusable code. And it do it very 
well.

Best regards,
Kamil

środa, 23 listopada 2022 o 05:27:08 UTC+1 ren...@ix.netcom.com napisał(a):

> That seems nonsensical to me. What is the square root of a string?
>
> Types aka classes define properties and behavior. 
>
> Cars do not fly. Planes don’t use roads. Classes are abstractions that 
> model required attributes that in turn compose a system to do useful work. 
> Both boats and cars move. You can use a boat to get from a to b if there is 
> no water. 
>
> Go is OO like. Or Go is not OO. There’s reasoning to support both but 
> don’t mangle OO to make the claim. 
>
> On Nov 22, 2022, at 11:04 AM, 'Thomas Bushnell BSG' via golang-nuts <
> golan...@googlegroups.com> wrote:
>
> 
>
> Late binding means you don't need to know the types of your parameters *at 
> all* when you write a method call. If the language supported late binding, 
> then you would be able to define all your variables as Object and 
> *everything would continue to work*. 
>
> In Go you could define everything as interface{} and then use small 
> interfaces around every call:
>
> foo.(interface{ Method() string}).Method()
>
> In Java, you can use the reflection interface. In this sense, it is 
> available "on demand", but that's not the same thing at all.
>
> Both Java and C++ made the mistake of confusing a class with a behavior, 
> and then using classes as names for behaviors.
>
>
>
> On Tue, Nov 22, 2022 at 11:46 AM Robert Engels  
> wrote:
>
>> What would be the purpose of writing B calling a method on A that doesn’t 
>> exist?
>>
>> On Nov 22, 2022, at 10:36 AM, 'Thomas Bushnell BSG' via golang-nuts <
>> golan...@googlegroups.com> wrote:
>>
>> 
>> Both Java and Go require that a method be instantiated in the declared 
>> interface of the type at compile time. This is contrary to the point of 
>> late binding.
>>
>> In the case of Go, this cannot be detected, because everything is built 
>> together. But with Java, you cannot call a method on an object unless that 
>> method has *already *been defined. In other words, late binding supports 
>> the following order of things:
>>
>> 1) Write class A, with method X and only X. Compile it.
>> 2) Write class B, which instantiates class A and calls method Y (which 
>> does not exist yet). Compile it.
>> 3) Extend class A to add method Y. Compile it.
>> 4) Execute class B.
>>
>> Late binding says this should work, but the Java compiler will throw an 
>> error at step two. Go never throws that error, because Go only builds the 
>> whole program at once, so the partial compilations don't make sense.
>>
>> In addition, any method marked final does not support late binding - 
>> indeed, this is the point of the keyword, and is why I remarked that this 
>> is because they couldn't figure out how to do it efficiently.
>>
>> Thomas
>>
>> On Tue, Nov 22, 2022 at 11:25 AM Robert Engels  
>> wrote:
>>
>>> Why do you say that Java does not have late binding. It 100% does. In 
>>> fact the JVM supports dynamic dispatch to make this as efficient as 
>>> possible. Then the JIT optimizes it even more based on runtime behavior. 
>>>
>>> On Nov 22, 2022, at 10:18 AM, Matt KØDVB  wrote:
>>>
>>> 
>>> But see https://en.wikipedia.org/wiki/Self_(programming_language)
>>>
>>> Self was considered an OO language back when I was a grad student and is 
>>> still listed that way today, even though it has neither classes nor 
>>> inheritance.
>>>
>>> Anyway, my point would be that the term OO originates with Alan Kay and 
>>> the team at Xerox PARC; Kay’s response to the OO flame wars was to 
>>> de-emphasize classes and inheritance.
>>>
>>> Of course, using his definition, neither Java nor Go would be “truly” OO 
>>> since not all things use late binding :-)
>>>
>>> Perhaps we can talk about class-based and non-class based OO languages?
>>>
>>> On Tue, Nov 22, 2022 at 10:07 AM Robert Engels  
>>> wrote:
>>>
 The wiki OO page lists classes as a requirement - but not necessarily 
 inheritance. Class variables require classes. 

 Also, your link does not work. 

 > On Nov 22, 2022, at 9:56 AM, Jan Mercl <0xj...@gmail.com> wrote:
 > 
 > On Tue, Nov 22, 2022 at 4:43 PM Robert Engels  
 wrote:
 > 
 >> Go is not listed as an OO language on Wikipedia.
 > 
 > Check https://en.wikipedia.org/wiki/Go_(programming_language):
 

Re: [go-nuts] where is GOROOT set?

2022-11-23 Thread 'Sean Liao' via golang-nuts
output of `go env` please

- sean


On Wed, Nov 23, 2022 at 11:25 PM pat2...@gmail.com 
wrote:

> I've separated my code into separate subdirectories, added a go.mod
> ran go mod tidy on each.
>
> I'm mostly back where I started, which a better source file tree
>
> I'm trying to test the "treesort" package from the "Donovan and Kernigan"
> The Go programing language book.
>
> When I connect into the treesort subdirectory, you can see the files, but
> I get a bad GOROOT error trying to do a "go test ."
>
> treesort$ ls
> go.mod  treesort.go  treesort_test.go
>
>
> pfarrell@Alien15:~/whome/sandbox/gows/treesort$ cat go.mod
> module github.com/pfarrell51/gows/treesort
>
> go 1.19
>
> pfarrell@Alien15:~/whome/sandbox/gows/treesort$ go test .
> # github.com/pfarrell51/gows/treesort
> treesort_test.go:11:2: package treesort is not in GOROOT (C:\Program
> Files\Go\src\treesort)
> FAILgithub.com/pfarrell51/gows/treesort [setup failed]
> FAIL
>
> How can I get past this?
> Thanks
> Pat
>
> --
> 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/4b365c67-6f3d-4edc-97d5-dbe505604818n%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/CAGabyPq5pSoL6w1Mbgj2A7ip7OuL2q1_hok7DBfcFK77fpxp-Q%40mail.gmail.com.


Re: [go-nuts] where is GOROOT set?

2022-11-23 Thread pat2...@gmail.com
I've separated my code into separate subdirectories, added a go.mod
ran go mod tidy on each.

I'm mostly back where I started, which a better source file tree

I'm trying to test the "treesort" package from the "Donovan and Kernigan" 
The Go programing language book.

When I connect into the treesort subdirectory, you can see the files, but I 
get a bad GOROOT error trying to do a "go test ."

treesort$ ls
go.mod  treesort.go  treesort_test.go


pfarrell@Alien15:~/whome/sandbox/gows/treesort$ cat go.mod
module github.com/pfarrell51/gows/treesort

go 1.19

pfarrell@Alien15:~/whome/sandbox/gows/treesort$ go test .
# github.com/pfarrell51/gows/treesort
treesort_test.go:11:2: package treesort is not in GOROOT (C:\Program 
Files\Go\src\treesort)
FAILgithub.com/pfarrell51/gows/treesort [setup failed]
FAIL

How can I get past this?
Thanks
Pat

-- 
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/4b365c67-6f3d-4edc-97d5-dbe505604818n%40googlegroups.com.


[go-nuts] Re: How to High-pass filter method for well height data

2022-11-23 Thread pat2...@gmail.com
You want to find a discrete fast fourier transform package.
convolve with a suitable filter, and then inverse the DFFT


-- 
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/281723e4-f401-4f4c-8c51-684c2f13914bn%40googlegroups.com.


Re: [go-nuts] any Go based supervisor alternative?

2022-11-23 Thread robert engels
It seems if you do it that way - you get all or nothing. Meaning if you have 
access to the socket - you can issue any command that is registered, and also 
start/stop any service with no further access controls.

Still, I looked at the code you referenced, and if you look at the caller here 
https://github.com/canonical/pebble/blob/727a82ae61756dca123d4e3a4b5d99b78f6e4bd8/internal/daemon/daemon.go#L221

It appears the user will always be nil - as userFromRequest() always returns 
nil - and no user authorization or access checking will be attempted. Unless I 
am missing something? Maybe the github source browser isn’t cross referencing 
as I would expect.

I would be very careful using a service orchestration system that hasn’t had a 
full security audit - there are almost backdoors lurking that can be exposed.






> On Nov 23, 2022, at 4:19 PM, Ben Hoyt  wrote:
> 
> I presume you're referring to API access? I wasn't around when the initial 
> API and access control stuff was designed (it's inherited from snapd), but 
> here's my understanding of how it works. The bulk of the API is exposed using 
> HTTP-over-unix-socket, so is only accessible if you have permission to access 
> the unix socket file. The access control handling code is at 
> https://github.com/canonical/pebble/blob/727a82ae61756dca123d4e3a4b5d99b78f6e4bd8/internal/daemon/daemon.go#L153
>  
> 
> 
> There are a couple of API endpoints exposed via ordinary HTTP-over-TCP if you 
> specify the "-http" command line arg, but those are very narrow, basically 
> the "health" endpoint which returns true/false. See the two "GuestOK: true" 
> endpoints here: 
> https://github.com/canonical/pebble/blob/727a82ae61756dca123d4e3a4b5d99b78f6e4bd8/internal/daemon/api.go#L27
>  
> 
> 
> We use Pebble mostly in a Kubernetes context with a sidecar container in the 
> pod talking to Pebble in another container in the same pod. This is done via 
> the unix socket file in the Pebble container which is mounted in the sidecar 
> container. People outside the pod can only access the GuestOK health endpoint 
> (we use this for Kubernetes probes).
> 
> Thanks for taking a look. We may well be missing something!
> 
> -Ben
> 
> 
> On Thu, Nov 24, 2022 at 10:41 AM Robert Engels  > wrote:
> I took a look at Pebble. I don’t see anything related to auth and credentials 
> and it seems like a huge back door security hole. 
> 
> Did I miss something?
> 
>> On Nov 23, 2022, at 3:20 PM, ben...@gmail.com  
>> mailto:benh...@gmail.com>> wrote:
>> 
>> 
>> Part of my day job is working on Canonical's "Pebble" 
>> (https://github.com/canonical/pebble ), 
>> a simple service manager written in Go. Unique features: layered 
>> configuration, and an HTTP-over-unix-socket API. It's GPLv3 licensed.
>> 
>> -Ben
> 
> 
> -- 
> 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/CAL9jXCEYnaZtuZFJC%3Da0mUXo6dU3ze6j89MEKGHWuvk3HEhC6g%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/76EE0DA4-52E4-43B5-98ED-3C566747206E%40ix.netcom.com.


Re: [go-nuts] Re: any Go based supervisor alternative?

2022-11-23 Thread Ben Hoyt
I presume you're referring to API access? I wasn't around when the initial
API and access control stuff was designed (it's inherited from snapd), but
here's my understanding of how it works. The bulk of the API is exposed
using HTTP-over-unix-socket, so is only accessible if you have permission
to access the unix socket file. The access control handling code is at
https://github.com/canonical/pebble/blob/727a82ae61756dca123d4e3a4b5d99b78f6e4bd8/internal/daemon/daemon.go#L153

There are a couple of API endpoints exposed via ordinary HTTP-over-TCP if
you specify the "-http" command line arg, but those are very narrow,
basically the "health" endpoint which returns true/false. See the two
"GuestOK: true" endpoints here:
https://github.com/canonical/pebble/blob/727a82ae61756dca123d4e3a4b5d99b78f6e4bd8/internal/daemon/api.go#L27

We use Pebble mostly in a Kubernetes context with a sidecar container in
the pod talking to Pebble in another container in the same pod. This is
done via the unix socket file in the Pebble container which is mounted in
the sidecar container. People outside the pod can only access the GuestOK
health endpoint (we use this for Kubernetes probes).

Thanks for taking a look. We may well be missing something!

-Ben


On Thu, Nov 24, 2022 at 10:41 AM Robert Engels 
wrote:

> I took a look at Pebble. I don’t see anything related to auth and
> credentials and it seems like a huge back door security hole.
>
> Did I miss something?
>
> On Nov 23, 2022, at 3:20 PM, ben...@gmail.com  wrote:
>
> 
> Part of my day job is working on Canonical's "Pebble" (
> https://github.com/canonical/pebble), a simple service manager written in
> Go. Unique features: layered configuration, and an HTTP-over-unix-socket
> API. It's GPLv3 licensed.
>
> -Ben
>
>

-- 
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/CAL9jXCEYnaZtuZFJC%3Da0mUXo6dU3ze6j89MEKGHWuvk3HEhC6g%40mail.gmail.com.


[go-nuts] Problems with array slicing reliability?

2022-11-23 Thread Mucas Schlack
Hello Golangers!
Is there anyone who can test the reliability of the following Golang slice 
feature? I am using an AMG64 computer with Windows 10, and Go version 
0.36.0. When I use the following code, to detect and then replace a 
character at any given length *n* (9) in a string with an Uppercase 
Character. Strangely and somehow, the slice pointer will move to another 
position even though the code is not dynamic and has not changed. Is there 
anyone who can trouble shoot this code for me?

Please remember that this is "*test*" code only, so some of it will not 
make any sense or work. It is only "proof of concept" code.

The code to pay attention to is the following - from lines: 80 - 92!

Many thanks for any help you can give!

Mucas

Example code:

package main

import(
//"unicode/utf8"
"math/rand"
"strconv"
"strings"
"fmt"
"time"
"os"
)

var alphanumerics = [62] string {

"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",
"0","1","2","3","4","5","6","7","8","9",

"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",
}

func main(){

var (
txtflpth string = "C:\\Workspace\\Transaction Hash.txt"
flNm string = "Transaction Hash.txt"
CRLF string = "\n"
cntstrt string
AuthKey string
NwStr string
cstart int
cntr int
flEx *os.FileInfo
flEx2 *os.File
trfl *os.File
err error
) 

fmt.Print("State where the hash counter should begin:>> ")
fmt.Scanln()

if cntstrt == "" || cntstrt == " " { 
trfl, err = os.Create(flNm)

if err != nil { panic(err); os.Exit(-1) }
defer trfl.Close() 

} else {
var flEx, err = os.Stat(txtflpth)

fmt.Println(flEx.Mode().String)
//fmt.Println(flEx.IsRegular())
fmt.Println(flEx.IsDir())
fmt.Println(flEx.Name())
fmt.Println(flEx.Size())
fmt.Println(flEx.Sys())

if err != nil { if os.IsNotExist(err) { panic(err) } }

cstart, err = strconv.Atoi(cntstrt)
flEx2, err := os.Open(txtflpth)
defer flEx2.Close() 
}

/*defer func(
if err == trfl.Close() || err == os.IsNotExist(err)!= err { 
panic(err) }
if err == flEx.Close() || err == os.IsNotExist(err)!= err { 
panic(err) }
)*/

if cntstrt != "" && cntstrt != " " { cntr = cstart }

for cntr = cstart; cntr < cstart + 1000; cntr++ {
NwStr = ""
AuthKey = NwStr

for i := 0; i <= 65; i++ {
time.Sleep(10 * time.Nanosecond)
rand.Seed(time.Now().UnixNano()) 
AuthKey = AuthKey + alphanumerics[rand.Intn(62)] //, [A - Z], 
[0-9])
}

var hashRemap = [...] string {"A","U","G","D","E","X"}

AuthKey = "0x" + AuthKey
fmt.Println("Transaction Hash: " + strconv.Itoa(cntr) + ") " + 
AuthKey)
//AuthKey2 := []rune(AuthKey)

StrPos := strings.Index(AuthKey, AuthKey[9:10])
fmt.Printf("The old character %s is at string position: (%d) " + 
CRLF,AuthKey[9:10], StrPos)
//os.Exit(1)

for i := 0; i < 6; i++ {
switch i {
case 0: AuthKey = strings.Replace(AuthKey,AuthKey[9:10], 
hashRemap[0], 1); fmt.Println("Replaced! The New Transaction Hash: " + "(" 
+ strconv.Itoa(i) + ") " + AuthKey); os.Exit(1);
case 1: AuthKey = strings.Replace(AuthKey,"", hashRemap[1], 
1)
case 2: AuthKey = strings.Replace(AuthKey,"", hashRemap[3], 
1) 
case 3: AuthKey = strings.Replace(AuthKey,"", hashRemap[4], 
1)
case 4: AuthKey = strings.Replace(AuthKey,"", hashRemap[5], 
1)
case 5: AuthKey = strings.Replace(AuthKey,"", hashRemap[5], 
1)
}

}

fmt.Println("Transaction Hash: " + strconv.Itoa(cntr) + ") " + 
AuthKey)
if trfl != nil { trfl.WriteString("Transaction Hash: " + 
strconv.Itoa(cntr) + ") " + AuthKey + CRLF) }
if flEx != nil { flEx2.WriteString("Transaction Hash: " + 
strconv.Itoa(cntr) + ") " + AuthKey + CRLF) }

-- 
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/f27c55aa-836a-453e-a013-a7b752de273bn%40googlegroups.com.


Re: [go-nuts] Re: any Go based supervisor alternative?

2022-11-23 Thread Robert Engels
I took a look at Pebble. I don’t see anything related to auth and credentials 
and it seems like a huge back door security hole. 

Did I miss something?

> On Nov 23, 2022, at 3:20 PM, ben...@gmail.com  wrote:
> 
> 
> Part of my day job is working on Canonical's "Pebble" 
> (https://github.com/canonical/pebble), a simple service manager written in 
> Go. Unique features: layered configuration, and an HTTP-over-unix-socket API. 
> It's GPLv3 licensed.
> 
> -Ben
> 
 On Monday, July 21, 2014 3:51:12 PM UTC-7, ChrisLu wrote:
 I am tasked to start a go service in a python shop. However, for 
 production environments, we have to use python based supervisord to manage 
 the Go process if it ever goes down.
 
 The Go deployment is extremely easy. But the python setup is just painful 
 to automate (compared with Go code).
 
 How do you manage the Go service on production and restart the Go service 
 if it goes down?
 
 Chris
 
> 
> -- 
> 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/b29d35cb-0d95-4a0e-a869-842d56dead8bn%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/18CB891C-C1B9-4807-B69A-D428AC65B355%40ix.netcom.com.


Re: [go-nuts] Re: any Go based supervisor alternative?

2022-11-23 Thread Robert Engels
I would manage this externally. As complex as Kubernetes or as simple as initd. 
 

> On Nov 23, 2022, at 1:01 PM, Mathieu CARBONNEAUX  
> wrote:
> 
> https://github.com/ochinchina/supervisord is a go version of supervisord
> 
>> Le mercredi 23 juillet 2014 à 03:02:36 UTC+2, kard...@gmail.com a écrit :
>> godoc.org/bitbucket.org/kardianos/service
>> 
>>> On Monday, July 21, 2014 3:51:12 PM UTC-7, ChrisLu wrote:
>>> I am tasked to start a go service in a python shop. However, for production 
>>> environments, we have to use python based supervisord to manage the Go 
>>> process if it ever goes down.
>>> 
>>> The Go deployment is extremely easy. But the python setup is just painful 
>>> to automate (compared with Go code).
>>> 
>>> How do you manage the Go service on production and restart the Go service 
>>> if it goes down?
>>> 
>>> Chris
>>> 
> 
> -- 
> 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/c9c2c380-ea48-4d0b-87d7-311c1e855379n%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/957742D8-2C07-4618-A96C-D70B04C5B120%40ix.netcom.com.


[go-nuts] Re: any Go based supervisor alternative?

2022-11-23 Thread ben...@gmail.com
Part of my day job is working on Canonical's "Pebble" 
(https://github.com/canonical/pebble), a simple service manager written in 
Go. Unique features: layered configuration, and an HTTP-over-unix-socket 
API. It's GPLv3 licensed.

-Ben

On Monday, July 21, 2014 3:51:12 PM UTC-7, ChrisLu wrote:
>>>
>>> I am tasked to start a go service in a python shop. However, for 
>>> production environments, we have to use python based supervisord to manage 
>>> the Go process if it ever goes down.
>>>
>>> The Go deployment is extremely easy. But the python setup is just 
>>> painful to automate (compared with Go code).
>>>
>>> How do you manage the Go service on production and restart the Go 
>>> service if it goes down?
>>>
>>> Chris
>>>
>>>

-- 
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/b29d35cb-0d95-4a0e-a869-842d56dead8bn%40googlegroups.com.


Re: [go-nuts] cgo Handle doc

2022-11-23 Thread Ian Lance Taylor
On Wed, Nov 23, 2022 at 9:25 AM Frédéric De Jaeger
 wrote:
>
> There is something that puzzles me a lot in the doc about cgo.Handle there 
> https://pkg.go.dev/runtime/cgo.  It says:
>
> Some C functions accept a void* argument that points to an arbitrary data 
> value supplied by the caller. It is not safe to coerce a cgo.Handle (an 
> integer) to a Go unsafe.Pointer, but instead we can pass the address of the 
> cgo.Handle to the void* parameter, as in this variant of the previous example:
>
> I was under the impression that casting a uintptr to an  unsafe.Pointer just 
> to call a C function (that accepts a  void*) is somewhat valid. (This is not 
> clearly  specified as a valid case in the doc of unsafe.Pointer, so, it might 
> be invalid from a very pedantic point of view).
>
> The advice given in the doc looks worst.  Taking the address of a local 
> variable and giving it to C looks even more undefined (if C stores the 
> pointer and reuse it after the original call returns).
>
> Don't we have a doc issue there ?
>
> I know that in C, the conversion uintptr -> void* is subject to debate (trap 
> representation, ...).  In practice, nobody cares because It just works. 
> (example of the nobody cares 
> https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/glib/glib-Type-Conversion-Macros.html)
>
> In practice, I'm almost certain that the naïve code that just gives the 
> cgo.Handle to a C function as a void* is *much* safer that the pattern 
> suggested in the doc.
>
> So should the doc be changed, or am I missing some important piece ?

It is not safe to convert a uintptr to an unsafe.Pointer when calling
a C function.  The docs in the unsafe package are intended to be
precise, and in particular the compiler is aware of them.  The
compiler applies special handling to a conversion from unsafe.Pointer
to uintptr in the argument to a function with no body like
syscall.Syscall.  That special handling does not occur in calls to cgo
functions.  While it will often work in practice, there are cases
where it will fail.

One way to handle this kind of case is to write a tiny C wrapper in
the cgo comment that takes a uintptr and does the conversion to void*
in C.  That conversion is safe, because the Go runtime will not be
aware of it and will never mistakenly treat the uintptr value as a
pointer value.

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/CAOyqgcWbB0k1pffy2j7GA0fOj3mGQ%3DG9M0CKc_%2BRhoLLJ9iJDg%40mail.gmail.com.


[go-nuts] Re: any Go based supervisor alternative?

2022-11-23 Thread Mathieu CARBONNEAUX
https://github.com/ochinchina/supervisord is a go version of supervisord

Le mercredi 23 juillet 2014 à 03:02:36 UTC+2, kard...@gmail.com a écrit :

> godoc.org/bitbucket.org/kardianos/service
>
> On Monday, July 21, 2014 3:51:12 PM UTC-7, ChrisLu wrote:
>>
>> I am tasked to start a go service in a python shop. However, for 
>> production environments, we have to use python based supervisord to manage 
>> the Go process if it ever goes down.
>>
>> The Go deployment is extremely easy. But the python setup is just painful 
>> to automate (compared with Go code).
>>
>> How do you manage the Go service on production and restart the Go service 
>> if it goes down?
>>
>> Chris
>>
>>

-- 
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/c9c2c380-ea48-4d0b-87d7-311c1e855379n%40googlegroups.com.


[go-nuts] How to High-pass filter method for well height data

2022-11-23 Thread TAERHEE
Hi all,

I am new to go, for studying engineer graduate course for late age at night 
school

My senior college want to test me digital filter with the well logging data.
It must be done with go-lang.
If I failed, I have to buy dinner for 10 people for the group test LOL.

this data was sampled between 60 second per 1 sample.
the sample rate was 0.0166Hz.

I looked for dsp filter through the gitbub, but the bandpass filter was 
focused always.

Is there anyone who help me PLZ

Highpass filter with 0.01Hz ( cutoff frequency ) and save the data.

Is there a quite good package for DSP, PLZ let me know
and the method file IO and apply HPF with GOLANG also. PLZ.

I looked quite many package with several days, 
but file IO and grammer was quite difficult, since I learned Golang 1 
month...

Thanks much,

TaeRhee

-- 
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/92aecf95-8d61-440f-8440-e19fa088352dn%40googlegroups.com.
738683.00 28.0
738683.000694 28.0
738683.001389 29.0
738683.002083 29.0
738683.002777 29.0
738683.003472 29.0
738683.004167 29.0
738683.004861 29.0
738683.005556 29.0
738683.006250 29.0
738683.006945 29.0
738683.007639 29.0
738683.008333 29.0
738683.009028 29.0
738683.009722 29.0
738683.010416 29.0
738683.01 29.0
738683.011806 29.0
738683.012500 29.0
738683.013195 29.0
738683.013889 29.0
738683.014583 29.0
738683.015278 29.0
738683.015972 29.0
738683.016667 29.0
738683.017361 29.0
738683.018055 29.0
738683.018750 29.0
738683.019444 29.0
738683.020139 29.0
738683.020834 29.0
738683.021528 29.0
738683.02 29.0
738683.022917 29.0
738683.023611 29.0
738683.024305 29.0
738683.025000 29.0
738683.025694 29.0
738683.026389 29.0
738683.027083 29.0
738683.027778 29.0
738683.028473 29.0
738683.029167 29.0
738683.029861 29.0
738683.030556 29.0
738683.031250 29.0
738683.031944 29.0
738683.032639 29.0
738683.03 29.0
738683.034027 29.0
738683.034722 29.0
738683.035417 29.0
738683.036111 29.0
738683.036806 29.0
738683.037500 28.0
738683.038195 29.0
738683.038889 29.0
738683.039583 29.0
738683.040278 29.0
738683.040972 29.0
738683.041666 29.0
738683.042361 29.0
738683.043056 29.0
738683.043750 29.0
738683.05 29.0
738683.045139 29.0
738683.045833 29.0
738683.046528 29.0
738683.047222 29.0
738683.047917 29.0
738683.048611 29.0
738683.049305 29.0
738683.05 29.0
738683.050694 29.0
738683.051389 29.0
738683.052084 29.0
738683.052778 29.0
738683.053472 29.0
738683.054167 29.0
738683.054861 30.0
738683.05 30.0
738683.056250 30.0
738683.056944 30.0
738683.057639 30.0
738683.058333 30.0
738683.059028 30.0
738683.059723 30.0
738683.060417 29.0
738683.06 30.0
738683.061806 30.0
738683.062500 30.0
738683.063194 30.0
738683.063889 30.0
738683.064583 30.0
738683.065277 30.0
738683.065972 30.0
738683.07 30.0
738683.067361 30.0
738683.068056 30.0
738683.068750 29.0
738683.069445 29.0
738683.070139 29.0
738683.070833 29.0
738683.071528 29.0
738683.07 30.0
738683.072916 30.0
738683.073611 30.0
738683.074306 30.0
738683.075000 30.0
738683.075695 30.0
738683.076389 29.0
738683.077083 30.0
738683.08 30.0
738683.078472 30.0
738683.079167 30.0
738683.079861 30.0
738683.080555 30.0
738683.081250 29.0
738683.081944 29.0
738683.082639 30.0
738683.083334 30.0
738683.084028 30.0
738683.084722 

[go-nuts] cgo Handle doc

2022-11-23 Thread Frédéric De Jaeger
Hi,
There is something that puzzles me a lot in the doc about cgo.Handle there 
https://pkg.go.dev/runtime/cgo.  It says:


*Some C functions accept a void* argument that points to an arbitrary data 
value supplied by the caller. It is not safe to coerce a cgo.Handle (an 
integer) to a Go unsafe.Pointer, but instead we can pass the address of the 
cgo.Handle to the void* parameter, as in this variant of the previous 
example: *

I was under the impression that casting a uintptr to an  unsafe.Pointer 
just to call a C function (that accepts a  void*) is somewhat valid. (This 
is not clearly  specified as a valid case in the doc of unsafe.Pointer, so, 
it might be invalid from a very pedantic point of view).

The advice given in the doc looks worst.  Taking the address of a local 
variable and giving it to C looks even more undefined (if C stores the 
pointer and reuse it after the original call returns).

Don't we have a doc issue there ?

I know that in C, the conversion uintptr -> void* is subject to debate 
(trap representation, ...).  In practice, nobody cares because *It just 
works*. (example of the nobody 
cares 
https://www.freedesktop.org/software/gstreamer-sdk/data/docs/latest/glib/glib-Type-Conversion-Macros.html)

In practice, I'm almost certain that the naïve code that just gives the 
cgo.Handle to a C function as a void* is *much* safer that the pattern 
suggested in the doc.

So should the doc be changed, or am I missing some important piece ?

Thanks
Fred

-- 
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/49cadd8f-89b4-4f91-8ad3-241768758dc3n%40googlegroups.com.


Re: [go-nuts] Shellquote in stdlib

2022-11-23 Thread 'Christian Stewart' via golang-nuts
Kurtis,

This is what I'm trying to accomplish:

Start delve (dlv) with os/exec passing a set of []string os.Args as
--build-flags

Let's say I have this build arguments set: []string{"-gcflags", "-N -l"}

 - How can I pass this to --build-flags in Delve? strings.Join(flags,
" ") is wrong.
 - How can I pass this to "go" with os/exec correctly? The quotes are
not put properly.

There are some cross-platform cases where the shell quoting is used,
and the general "quote something" mechanics are similar on Windows and
Linux.

Thanks,
Christian

On Sun, Nov 6, 2022 at 9:11 PM Kurtis Rader  wrote:
>
> On Sun, Nov 6, 2022 at 8:48 PM 'Christian Stewart' via golang-nuts 
>  wrote:
>>
>> There have been several discussions about shellquote in go-nuts in the past:
>>
>> https://github.com/kballard/go-shellquote
>> https://github.com/gonuts/go-shellquote
>>
>> I've found it necessary to use both Split and Join in some cases when 
>> working with exec.Command.
>>
>> This seems like the type of thing that ought to be part of the stdlib, has 
>> there been any consideration towards including it or a similar 
>> implementation?
>>
>> This is useful for processing os.Args especially in CLI or emulated shell 
>> environments.
>
>
> No, IMHO, because such quoting is OS specific. For example, the quoting for 
> UNIX and Windows in this context are different. Furthermore, given the 
> vagaries of the POSIX shell standard I am skeptical that either of the 
> projects you linked to correctly manipulates such strings in every case.
>
> It would help if you provided a concrete example of the problem you need help 
> with.
>
> --
> 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/CA%2Bh8R2pNLqaM2%3DK4%3DYdKhmWTAEAEna3k7KkQHqRVed%3D3RemKQQ%40mail.gmail.com.