Re: [go-nuts] Go Create

2021-01-12 Thread Jim Ancona
I have a third use case for replace:

3. Simultaneously developing a library and client for that library. For
example, if I have a library to access a network service or piece of
hardware and want to extend its API, I find that working on the client
along with the library helps me iterate to a good API. I use replace to get
that to work. But I think that newcomers to the language are unlikely to
run into that case either.

Jim

On Tue, Jan 12, 2021 at 9:26 AM 'Axel Wagner' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> On Tue, Jan 12, 2021 at 2:49 PM Kevin Chadwick 
> wrote:
>
>> On 1/12/21 12:37 PM, Axel Wagner wrote:
>> > Again, would be interesting how other languages can make this simpler,
>> because I
>> > genuinely can't imagine.
>>
>> The issue is that I believe go avoids files in order to speed up
>> compilation.
>>
>
> I don't believe it is.
>
>
>> It's just I don't believe the replace directive was meant for this and
>> yet upon googling.
>
>
> I tend to agree. I still do not understand why you feel the need to use
> it. It has two fairly limited uses: 1. overwrite the dependency of one of
> your dependencies, e.g. to use a fork which contains critical patches you
> need. And 2. work with a local fork of a dependency, for experimentation
> (e.g. to find a bug or try out an unpublished API). Neither of these are
> things that should be encountered by newcomers to the language - or very
> often at all.
>
> If you are using replace as part of your regular workflow, I do agree that
> you are probably misusing it. It's just hard to understand why, from what
> you said so far (barring the "I don't have an internet connection and want
> to use something from my module cache" case, which I find surprising, if
> that's part of your regular workflow).
>
> It is the only way that I have found. mod
>> vendor doesn't seem to do what I want.
>>
>> They are fairly similar otherwise.
>>
>> Flutter create
>> open lib/main.dart
>> add import to file locations in any dart files where you wish to access
>> that
>> particular code (like in most languages)
>> add package to pubspec.yaml
>> IDE asks to run flutter pub get
>> add import referencing package where needed
>>
>> vs
>>
>> go mod init
>> edit .mod with weird replace line that links a domain to a file location
>> add import matching replace directive domain/url
>> go get package
>> add import for the package
>>
>> As I said. I should probably just set up a local git server and sync up
>> that
>> way. symlinks were only an issue in some programs and only when using
>> Windows too.
>>
>> --
>> 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/8417466a-deb0-98f6-3635-3240278dbcc7%40gmail.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/CAEkBMfF6axmeHxYMecoHfR%2BhBVdto_froMGVswRYaoKYWodHnQ%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/CAKYY9A%2BKrPwHSK00VjQcsyZoKxumaHWoR-pUi1Jww7hfRtijBA%40mail.gmail.com.


Re: [go-nuts] Does your Windows app rely on os.Rename() or .Remove() ?

2019-07-03 Thread Jim Ancona
On Wed, Jul 3, 2019 at 1:09 PM Liam  wrote:

> [Sorry to keep re-posting this; I'm keeping it visible for infrequent
> readers]
>

I'm a frequent reader and I've now seen it four times. IMHO, that's enough.

Jim


>
> Microsoft recommends changing syscall.Open() for GOOS=windows to fix this.
> Pls reply if you know of existing apps that rely on it.
>
> This code fails with a "sharing violation" on Windows. That behavior is
> undocumented in package "os".
>
> path := "rename-after-open"
> fd, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0600)
> if err != nil { ... }
> err = os.Rename(path_a, path_b)// or os.Remove(path)
> if err != nil { ... }  // sharing violation
> fd.Close()
>
>
> In this issue, Microsoft suggested that Go on Windows switch to Unix-like
> behavior:
> https://github.com/golang/go/issues/32088
>
> --
> 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/1587c3db-4ce5-4572-bbb4-ed43c183d290%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAKYY9AKxboobAKk3SqgMUtrbtfRu0%2BaJfGorrEmf%3D7vVnag9cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Go Module Mirror and Checksum Database in Beta!

2019-05-31 Thread Jim Ancona
On Thu, May 30, 2019 at 5:14 PM Katie Hockman  wrote:

> Our privacy policy explains how we collect and use your information. The
> privacy policy for all of these services is proxy.golang.org/privacy.
>

I tried visiting that page, which redirected to
https://policies.google.com/privacy Unfortunately that page doesn't really
help me to understand what data you will collect from proxy.golang.org or
sum.golang.org and how you might use it. Is there a clear and simple
explanation of that available? If no, perhaps there should be.

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/CAKYY9A%2B02Czwy8xrd7bUW%2BNTYgvFHS-ogHR1r%3D9b1wx2CNpzZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Pointer based API and constants literals, how to best handle it?

2019-04-18 Thread Jim Ancona
Is your Cognito provider open source? I might have a use for that/

Jim

On Wed, Apr 17, 2019 at 3:55 PM whitehexagon via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> Thanks Jim, and for the sympathy :)  I'm almost tempted to use the REST
> API and bypass the SDK...  I already implemented a missing Cognito Provider
> using the web API, and it seemed friendlier than this.  It would be one
> less dependency too, since I'm deploying to AWS Lambda and I'm already at
> 14MB for my first Go based Lambda.
>
> Peter
>
>
> On Wednesday, 17 April 2019 21:29:31 UTC+2, Jim Ancona wrote:
>>
>> Having used the AWS SDK, I feel your pain. They do have built-in helper
>> methods, e.g. https://docs.aws.amazon.com/sdk-for-go/api/aws/#String, so
>> at least you don't have to define your own.
>>
>> Jim
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Pointer based API and constants literals, how to best handle it?

2019-04-17 Thread Jim Ancona
Having used the AWS SDK, I feel your pain. They do have built-in helper
methods, e.g. https://docs.aws.amazon.com/sdk-for-go/api/aws/#String, so at
least you don't have to define your own.

Jim

On Wed, Apr 17, 2019 at 2:22 PM whitehexagon via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> I'm still very new to Go, so apologies if this is obvious.  I'm porting
> some code over to Go, and the provided SDK I'm working with seems to want
> pointers everywhere.  However a lot of the values are constant / literals.
>
> So for example storing some data in the DB:
>
>
> https://docs.aws.amazon.com/sdk-for-go/api/service/simpledb/#PutAttributesInput
>
> My first thought was along the lines:
>
> field1 := ReplaceableAttribute{&"colA", &true, &"new value"}
> condition := UpdateCondition{&true, &"ColKey", &"Key"}
> input := PutAttributesInput{[]*ReplaceableAttribute{field1}, &"TABLE1",
> &condition", &"Key"}
>
> That was before reading a lot of historical debates about the merits of
> such syntax...  So assuming I dont want to create vars for every value, or
> helper functions, Is there a clean way of achieving the above?
> I can see that the API provides convenience setters for every struct
> attribute, but you can imagine it creates a lot of code bloat for quite
> simple functionality.  Any thoughts?
>
> Peter
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Is Go a single pass compiler?

2019-02-28 Thread Jim Ancona
The first computer I ever programmed[1] had a Fortran compiler that stored
its intermediate representation on paper tape. As you might imagine, the
number of passes affected compilation speed a lot. I don't do compilers,
but I suspect that other bottlenecks matter much more today.

Jim

[1] - https://en.wikipedia.org/wiki/Monrobot_XI

On Wed, Feb 27, 2019 at 6:46 PM  wrote:

> Thanks, Ian.
>
> I remember reading in some compiler book that languages should be designed
> for a single pass to reduce compilation speed.
>
> Go proves that wrong :) It's amazingly fast, looks like computers are
> pretty good at traversing AST trees.
>
> On Wednesday, February 27, 2019 at 11:50:05 PM UTC+1, Ian Lance Taylor
> wrote:
>>
>> On Wed, Feb 27, 2019 at 2:42 PM  wrote:
>> >
>> > In Go functions can be used before they are defined, but as I
>> understand, it's still possible to have a single pass compiler.
>>
>> I don't think it's possible to compile Go in a single pass compiler,
>> unless you consider a separate parsing and code generation step to be
>> a single pass compiler.  In the general case, you can't generate code
>> for any Go function until you've seen all the functions in the
>> package.
>>
>> There are multiple Go compilers.  All the ones I am aware of are have
>> many passes.
>>
>> Ian
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Issue with creating file on aws lambda

2018-10-16 Thread Jim Ancona
I'm pretty sure that the only writeable file system on Lambda in under
/tmp. You're not checking the error return from os.MkdirAll, but that call
is probably failing before you get to os.Create. Also keep in mind that
each Lambda instance is limited to 512 MB of /tmp space:
https://docs.aws.amazon.com/lambda/latest/dg/limits.html

Jim

On Tue, Oct 16, 2018 at 3:46 PM AE  wrote:

> Hello,
>
> I am trying to make function which will down file fro aws s3 and do some
> image resizing. I am having issue with os.Create, when I run locally on ec2
> machine it works fine but when I run on lambda directly I get error file
> not found
>
>
> package main
> import (
> "github.com/aws/aws-sdk-go/aws"
> "github.com/aws/aws-sdk-go/aws/session"
> "github.com/aws/aws-sdk-go/service/s3"
> "github.com/aws/aws-sdk-go/service/s3/s3manager"
> _ "github.com/aws/aws-lambda-go/lambda"
> _ "github.com/nfnt/resize"
>_ "image/jpeg"
> "fmt"
> "os"
>
> )
> type MyEvent struct {
> Name string `json:"name"`
> }
>
> func HandleRequest() (string, error) {
> runResize(
> "5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg")
> return fmt.Sprintf("Hello"), nil
> }
>
> func main() {
>  //   lambda.Start(HandleRequest)
> runResize("5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg")
>
> }
>
> func runResize(item_name string) {
> bucket := "bucket"
> folder_name := "images/users/original/"
> folder_name_220x220 := "images/users/220x220/"
> folder_name_250x250 := "images/users/250x250/"
> folder_name_500x500 := "images/users/500x500/"
> folder_name_large := "images/users/large/"
>
>
>
>
> createFolder(folder_name)
> createFolder(folder_name_220x220)
> createFolder(folder_name_250x250)
> createFolder(folder_name_500x500)
> createFolder(folder_name_large)
>
>
>
> item := folder_name + item_name
>
> fmt.Printf("Creating file %q \n", item)
> file, err :=  os.Create(item)
>
> if err != nil {
>
> exitErrorf("Unable to open file %q", err)
>
> }
> defer file.Close()
> sess, _ := session.NewSession(&aws.Config{
> Region: aws.String("us-east-1")},
> )
> downloader := s3manager.NewDownloader(sess)
> numBytes, err := downloader.Download(file,
> &s3.GetObjectInput{
> Bucket: aws.String(bucket),
> Key:aws.String(item),
> })
>
> if err != nil {
>
> exitErrorf("Unable to download item %q, %v", item, err)
>
> }
>fmt.Println("Processed", file.Name(), numBytes, "bytes")
> }
> func createFolder(folder_name string) {
> if _, err := os.Stat(folder_name); os.IsNotExist(err) {
> os.MkdirAll(folder_name, os.ModePerm)
> fmt.Printf("Folder created %q \n", folder_name)
> }
> }
>
> func exitErrorf(msg string, args ...interface{}) {
>
> fmt.Fprintf(os.Stderr, msg+"\n", args...)
>
> os.Exit(1)
>
> }
>
>
>
> Here how I build the code for deployment
>
>
> GOOS=linux go build -v -ldflags '-d -s -w' -a -tags netgo -installsuffix
> netgo -o resize && zip deployment.zip resize
>
>
> and error I am getting
>
>
> Unable to open file "open
> images/users/original/5bba5c0f01e2f_dcadcc7139454bf6dba4cbd01a7c92f8.jpeg:
> no such file or directory"
>
> This error i thrown on create on in LAMBDA
>
>
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Local cache of dependencies

2018-08-23 Thread Jim Ancona
I believe Athens (https://github.com/gomods/athens) is meant to address
this use case in the Go modules world.

Jim

On Wed, Aug 22, 2018 at 7:51 PM Conor Hackett  wrote:

> Thanks Sam,
>
> I'll have a look out of curiosity but I am very reluctant to
> introduce/recommend Git submodules to any of my projects. You might say
> it's because I don't understand how they work that I fear them but they
> have caused much heartache in the past and a recent team I was on had
> nothing but trouble as a whole. Surely there is a better way?
>
> I will look at it for inspiration though and I appreciate your reply :)
>
> Conor
>
> On Thursday, 23 August 2018 00:35:49 UTC+1, Sam Vilain wrote:
>>
>> Check out vendetta - it uses git submodules, so you keep a cache of the
>> 3rd party repo in git but not the actual content. You get small repos and
>> reproducible builds.
>>
>> Sam
>>
>> On Aug 22, 2018 3:25 PM, Conor Hackett  wrote:
>>
>> Hey Guys,
>>
>> So, adding your "vendor" directory to SCM is a contentious topic at best.
>>
>> I personally would rather not vendor the dependencies but I do need to
>> keep the required code in my control and I consider third party repos out
>> of my control.
>>
>> Similar to how maven works (and others I am sure), is there some tooling
>> that will enable me to cache/store/save third party dependencies on my
>> local machine/server etc in order to
>>
>> a) reduce operational risk of a repo/code disappearing
>> b) potentially speeding up build time
>>
>> This post is more of a sanity check -- I have been searching for such
>> tooling for a while now and am about to spin up a new project do something
>> along these lines.
>>
>> Thanks in advance.
>>
>> --
>> 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.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [go-nuts] Re: Choosing a framework

2017-09-14 Thread Jim Ancona
On Thu, Sep 14, 2017 at 1:28 AM, Vikram Rawat 
wrote:
>
> And there is another project called VECTY. But I mailed them and they told
> me it's not documented yet. and it could have bugs.
>

Vecty (https://github.com/gopherjs/vecty) uses Gopherjs and runs in the
browser, so it used for different things than the server-side frameworks
like Revel.

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


Re: [go-nuts] Invalid JSON document from 'go list -json std'

2016-08-23 Thread Jim Ancona
This is a pretty common way of streaming JSON objects. See:
https://en.wikipedia.org/wiki/JSON_Streaming

But I agree that it's not part of the JSON standard, nor does it seem to be
standardized anywhere else.

On Mon, Aug 22, 2016 at 9:43 PM, Matt Harden  wrote:

> The output is not a valid (single) JSON value. It's a number of JSON
> values, separated by newlines. jq considers each of these values a separate
> "input". There's nothing in the definition of JSON that makes this valid.
>
> On Mon, Aug 22, 2016 at 4:49 PM Edward Muller 
> wrote:
>
>> `go list -json std | jq` does not complain, which is my usual "is my json
>> valid" test.
>>
>> On Sat, Aug 20, 2016 at 12:13 PM Lars Tørnes Hansen 
>> wrote:
>>
>>> I expected that
>>> go list -json std
>>> ... would output a valid JSON document, because
>>> go help list
>>> writes:
>>> The -json flag causes the package data to be printed in JSON format
>>> instead of using the template format.
>>> but ...
>>>
>>>- The JSON document is not a JSON array
>>>- Between 2 JSON objects of type build.Package: A comma is missing
>>>
>>> go version go1.7 linux/amd64
>>>
>>> Have I misunderstood 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.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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