[go-nuts] package is not in goroot

2021-01-19 Thread Alexander Mills
i am getting this weird error message: package twitch/go-scripts/dynamo-creators-to-s3/lib is not in GOROOT (/usr/local/Cellar/go/1.15.6/libexec/src/twitch/go-scripts/dynamo-creators-to-s3/lib) my GOPATH=$PWD/scripts/go so there is only 1 GOPATH [image: Screen Shot 2021-01-19 at 1.52.30

[go-nuts] nil pointer ref can't figure out why

2021-01-18 Thread 'Alexander Mills' via golang-nuts
I have this line: fmt.Printlin("the dao:", dao); and it logs: the dao: &{ } the overall method looks like: func (dao *UserAttributeDao) GetDecryptedUserAttributes(workflowID string) (*PayoutUserAttributeRecord, error) { getItemInput := { TableName: aws.String(payoutUserAttributesTableName),

Re: [go-nuts] sql string not interpolated as expected

2021-01-03 Thread Alexander Mills
here is a question I posted on dba.stackexchange: https://dba.stackexchange.com/questions/282501/variable-number-of-arguments-with-golang On Sun, Jan 3, 2021 at 2:20 PM Alexander Mills wrote: > labels are variable arguments, so I don't know how to do it..i solved it > for the time

Re: [go-nuts] sql string not interpolated as expected

2021-01-03 Thread Alexander Mills
change the number of question-marks to match > len(labelStrs), but that's easily done with a helper function. It would be > nice if a placeholder could be a list and expand accordingly, though. > > On Sunday, 3 January 2021 at 09:29:25 UTC Reto wrote: > >> On Sun, Jan 03, 2021

[go-nuts] sql string not interpolated as expected

2021-01-03 Thread Alexander Mills
I have this: rows, err := c.Database.Db.Query(` select *, ( select count(*) from mbk_file_label where file_id = mbk_file.id and label_id IN ( select id from mbk_user_label where label_name IN ( 'carnivore', 'mammal', 'vertebrate' ) ) ) as xxx from mbk_file where user_id = $1 order by xxx DESC

Re: [go-nuts] how to get unsigned url (not signed url)

2020-12-24 Thread Alexander Mills
2020 at 5:54 PM Alexander Mills < > alexander.d.mi...@gmail.com> wrote: > >> this is a little irritating lol, i can get a signed url via: >> >> bucket := "bnk-photos" >> filename := "mypic3.json" >> method := "PUT" >&

Re: [go-nuts] how to get unsigned url (not signed url)

2020-12-21 Thread Alexander Mills
PM UTC+1 Kurtis Rader wrote: > >> On Mon, Dec 21, 2020 at 2:55 PM Alexander Mills >> wrote: >> >>> this is a little irritating lol, i can get a signed url via: >>> >>> bucket := "bnk-photos" >>> filename := "mypic3.json&quo

[go-nuts] how to get unsigned url (not signed url)

2020-12-21 Thread Alexander Mills
this is a little irritating lol, i can get a signed url via: bucket := "bnk-photos" filename := "mypic3.json" method := "PUT" expires := time.Now().Add(time.Minute * 10) url, err := storage.SignedURL(bucket, filename, { GoogleAccessID: cfg.Email, PrivateKey: cfg.PrivateKey, Method: method,

Re: [go-nuts] How to clear current line in terminal

2020-09-19 Thread Alexander Mills
Yeah sure so it looks like: clearCurrentLine() // clears the previous status line fmt.Println("foo") writeStatusLine() // writes new status line where clearCurrentLine() is just like func clearCurrentLine(){ //fmt.Printf("\033[0;") // clear current line //fmt.Printf("\033[2K\r%d",0);

[go-nuts] hook into os.Stdout / os.Stderr

2020-09-19 Thread Alexander Mills
Forgive me for this pigeon code, I am looking to do something like: os.Stdout.BeforeWrite(func (){ }); os.Stderr.AfterWrite(func(){ }) so I can hook into the system and clear the terminal before hand, and write a status line, after wards. Is this possible? -- You received this message

Re: [go-nuts] alloc vs totalalloc in memory

2020-09-10 Thread Alexander Mills
I stole the memory code from here: https://golangcode.com/print-the-current-memory-usage/ On Thu, Sep 10, 2020 at 4:39 PM Alexander Mills wrote: > > I have this helper func to print memory usage (detect a memory leak?) > > > func PrintMemUsage() { > var m runtime.MemStats >

[go-nuts] alloc vs totalalloc in memory

2020-09-10 Thread Alexander Mills
I have this helper func to print memory usage (detect a memory leak?) func PrintMemUsage() { var m runtime.MemStats runtime.ReadMemStats() // For info on each, see: https://golang.org/pkg/runtime/#MemStats fmt.Printf("Alloc = %v MiB", bToMb(m.Alloc)) fmt.Printf("\tTotalAlloc = %v MiB",

Re: [go-nuts] why is wait group necessary here?

2020-09-10 Thread Alexander Mills
It was behaving strangely before adding the waitgroup, my script was getting stuck On Thu, Sep 10, 2020 at 11:14 AM burak serdar wrote: > > On Thu, Sep 10, 2020 at 11:46 AM Alexander Mills > wrote: > > > > I tried writing this http post request which streams the request b

[go-nuts] why is wait group necessary in streaming post request to elasticsearch

2020-09-10 Thread Alexander Mills
I am trying to figure out why the wg is seemingly necessary as part of this code to stream JSON to a post request to ElasticSearch: https://gist.github.com/ORESoftware/06341057ca39e1b2a47dc8a8e4e4b55f Any tips appreciated. If the waitgroup is not used, it doesn't appear to wait until the full

[go-nuts] why is wait group necessary here?

2020-09-10 Thread Alexander Mills
I tried writing this http post request which streams the request body line-by-line as JSON. (This is for an ElasticSearch bulk api request, newline separate JSON in the request body). I didn't think the waitgroup was necessary, but apparently the waitgroup is necessary. Does anyone know why? I

[go-nuts] Re: how to omit empty array

2020-09-03 Thread Alexander Mills
y"` >MustNot []HasTermOrMatch `json:"must_not,omitempty"` >Filter []HasTermOrMatch `json:"filter,omitempty"` >Should []HasTermOrMatch `json:"should,omitempty"` > } > > This should omit the slice field in the serialized JSON if the slice is &

[go-nuts] how to declare type as interface{}

2020-09-03 Thread Alexander Mills
This works: var z interface{} if err := json.NewDecoder(resp.Body).Decode(); err != nil { t.Fatal(err) } but this doesn't work: if err := json.NewDecoder(resp.Body).Decode({}{}); err != nil { t.Fatal(err) } and this doesn't work: if err := json.NewDecoder(resp.Body).Decode({}{});

Re: [go-nuts] how to stream json to http post req

2020-09-02 Thread Alexander Mills
thanks that looks correct to me On Wednesday, September 2, 2020 at 2:16:30 PM UTC-7 bbse...@gmail.com wrote: > On Wed, Sep 2, 2020 at 2:49 PM Alexander Mills > wrote: > > > > I have the following code: > > > > ``` > > b := bytes.NewBuffer([]byte(""

[go-nuts] how to stream json to http post req

2020-09-02 Thread Alexander Mills
I have the following code: ``` b := bytes.NewBuffer([]byte("")) go func() { for _, v := range z { jsonStr, err := json.Marshal() if err != nil { continue } b.Write([]byte(string(jsonStr) + "\n")) } }() fullUrl := fmt.Sprintf("%s/%s", baseUrl, "_bulk") req, err := http.NewRequest("POST",

[go-nuts] how to omit empty array

2020-09-02 Thread Alexander Mills
I have this code used to construct an ElasticSearch json query: ``` type Term = map[string]interface{} type QueryString = map[string]interface{} type Range = map[string]interface{} type Match = map[string]string type HasTermOrMatch = struct { Term `json:"term,omitempty"` QueryString

Re: [go-nuts] First git commit for Go was in 1972? 勞

2020-08-05 Thread Alexander Mills
git didnt exist until 2009 or something lol On Wed, Aug 5, 2020 at 3:36 AM Mohamed Yousif wrote: > > I did small google search and here are the findings > > >Brian Kernighan actually wrote the first "hello, world" program as part of > >the documentation for the BCPL programming language. BCPL

[go-nuts] Getting this error: compile: version "go1.13.7" does not match go tool version "go1.12.10"

2020-04-09 Thread Alexander Mills
I have this go.mod file: module github.com/channelmeter/err-id-checker go 1.12 my go version is: *go version go1.12.10 linux/amd64 * my imports just look like this: package main import ( "bufio" "fmt" "io/ioutil" "log" "os" "path/filepath" "regexp" "strings" "sync" ) but when

[go-nuts] How to read http.Response from http.Request

2020-03-17 Thread Alexander Mills
hey all I am trying to read the Response from http.Request like so: func (ctr *Controller) Login(c *common.CPContext, req *http.Request, res http.ResponseWriter) (int, interface{}) { defer func() { var code = req.Response.StatusCode; // invalid memory address or nil

[go-nuts] Naming convention for "will return error if cannot be done"

2020-03-07 Thread Alexander Mills
I put the question on Quora: https://www.quora.com/unanswered/In-Golang-mustdo-means-it-will-panic-if-it-cannot-be-done-Is-here-a-naming-convention-for-will-always-return-error-if-it-cannot-be-done In Golang "mustdo" means it will panic() if it cannot be done. Is here a naming convention for

[go-nuts] implicit initialization in golang declarations?

2020-02-10 Thread Alexander Mills
I have been confused about this ever since I started working with Go: https://gist.github.com/ORESoftware/a6243ce1039cea7e49a22ec8daf90a82 we can do this: var wg sync.WaitGroup instead of having to write this: var wg sync.WaitGroup = sync.WaitGroup{} // is this initialization implicit,

[go-nuts] re: solving: panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

2020-02-08 Thread Alexander Mills
it looks like this way works: https://stackoverflow.com/a/43918797/12211419 know of any others? -- 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

[go-nuts] re: solving: panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

2020-02-08 Thread Alexander Mills
I am trying to get an answer to my github gist Q: https://gist.github.com/ORESoftware/9253433dc0f5af52df8eff7c26e689a0 if anyone knows if this is possible in Golang v1.13+ please lmk -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To