The usual way to do this is a function or method to convert from []string
to []interface{}: https://play.golang.org/p/VW-xs6E9xul
The correct approach is probably something different than "func
PrintAll(vals []interface{})". What are you trying to do?
Matt
On Tuesday, February 27, 2018 at 9:25
Hi Eyal, here’s a code review.
Perhaps there’s a simpler name? Something like “timing.Timer” would look
better than “clienttiming.Timer”.
return fmt.Sprintf("%s %s", req.Method, req.URL.Path)
could just be
return req.Method + “ “ + req.URL.Path
which removes the package fmt dependency.
The g
>
> I have now embarked on a mission to create an online game, using Go for
> the server.
What kind of online?
Making a server program to run on one computer in a private network is
different than a scaling Internet game on one of the cloud platforms. In
either case the microservice approach
Are the builds and deployment controlled? The command “go list” can be used
to simplify parsing the imports in each package, so a script could check
that every import is either an allowed standard library package or one
matching your internal URL.
Matt
On Wednesday, February 21, 2018 at 11:37:
>
> Since the `vendor` folder is gone, is vgo able to manage and use a kind of
> `mirror` folder, which would contain the .zip archives of the project
> dependencies? This folder could be committed with the project source code.
I have the same question. Can we vendor modules? Code consumers ma
Maybe something with GOROOT? From the release notes:
If the environment variable $GOROOT is unset, the go tool previously used
> the default GOROOT set during toolchain compilation. Now, before falling
> back to that default, the go tool attempts to deduce GOROOT from its own
> executable path.
This worked for me in a project. My form is
and the input is . On the server I
use r.ParseForm then r.FormValue("password").
Matt
On Tuesday, February 20, 2018 at 10:16:57 AM UTC-6, Sankar wrote:
>
> Hi,
>
> I have a Golang HTTP server which is consumed by mobile Apps via HTTP.
>
> For one wo
This worked for me. My form is "
> Password
>
> Repeat Password
> required>
> Change Password
>
>
>
> `
> res.WriteHeader(http.StatusOK)
> res.Header().Set("Content-Type", "text/html")
> res.Write([]byte(body))
> } else if req.Method == http.MethodPost {
> err := req.ParseForm()
> log.Println(
>
> This seems deeply insightful to me.
Thanks Michael.
It's not just maps, slices, append, and make. Every single operator could
> be considered too to be "generic" because each operates on an indefinite
> number of types.
> But Go gains much from the special-case syntax and semantics ass
>
> I would probably never use it, like many people who comes to Go from C.
But if you use maps, slices, append, make, you are already using generics.
Maybe this is unfounded, but I'm far from convinced that generics would
> make my experience of Go better. I'm really thinking here of, are we
Hi Serena, here’s a code review.
imports can be grouped with parenthesis:
import (
“fmt”
“bytes”
“testing”
“encoding/hex”
“github.com/deroproject/derosuite/config”
)
vars and consts are often grouped this way too. I see this is done
sometimes but mostly not.
package+type l
>
> Competition is good, only when the Go team feels the heat of competition
> they will think about working on their type system seriously.
I think everybody here is aware that some people really want generics and
that generics would probably be useful for everybody. Instead of restating
tha
Can you write some examples that use these types?
Matt
On Friday, February 16, 2018 at 6:37:47 AM UTC-6, dc0d wrote:
>
> “There are only two kinds of languages: the ones people complain about and
> the ones nobody uses.”
>
> ― Bjarne Stroustrup,
>
> I use other programming languages too - obviou
Well, what do you want to know? I’m not aware of good online resources for
people new to programming, but maybe we can help.
Matt
On Wednesday, February 14, 2018 at 7:40:47 AM UTC-6, Espinho wrote:
>
> Can someone point me out some good resources for learning Go as first
> programming language?
Serving to a locale may be helped with this
blog: https://blog.golang.org/matchlang
This library looks like it has implementations for finding the OS
locale: https://github.com/cloudfoundry-attic/jibber_jabber
Matt
On Wednesday, February 14, 2018 at 7:40:47 AM UTC-6,
prabhakara...@gmail.com w
The source for ioutil.ReadAll() shows that it can return a
bytes.ErrTooLarge or an error from the io.Reader.
So what you're saying is that unless the response contain chunked data,
> ioutil.ReadAll() will never fail?
I thought typically the http response isn’t buffered into memory first, so
t
We’ve been discussing stateless packages here:
https://github.com/golang/go/issues/23267
Matt
On Monday, February 12, 2018 at 1:43:05 PM UTC-6, dc0d wrote:
>
> Is there a way to identify a package as safe?
>
> Let's restrict the imported packages to built-in ones. Now assuming a
> package only
Closures and function types/fields may have a place in discussing OOP-like
Go constructs.
Matt
On Thursday, February 8, 2018 at 10:47:04 AM UTC-6, Stefan Nilsson wrote:
>
> Here is a short article about how to do OOP in Go with composition,
> structurally typed interfaces and, in some special c
I read that one of the Gang of Four has sadly died recently. To me their
book seems to be part of American technology history and tradition and I’m
glad to have a copy somewhere.
And, for structs that need stronger encapsulation (private fields, enforce
> invariants at construction time), Go ha
https://groups.google.com/forum/#!forum/gce-discussion may be a better
place to ask this question.
Here are the other GCP groups: https://cloud.google.com/support/docs/groups
Matt
On Wednesday, February 7, 2018 at 11:13:26 AM UTC-6, Sankar wrote:
>
> Hey Googlers,
>
> Any help on this ? I would
The select already received in that case and is waiting to send, but the
select has to be re-entered for the next receive to happen.
Matt
On Wednesday, February 7, 2018 at 9:22:31 AM UTC-6, Damon Zhao wrote:
>
> I know wrap with a goroutine can fix it. I just wonder why must use an
> extra goro
Desynchronizing "case idle <- <-source:" fixes it:
case v := <-source:
go func () { idle <- v }()
I added a counter to break after a number of loops since it goes
infinitely: https://play.golang.org/p/aZbmTKvpxcD
Matt
On Wednesday, February 7, 2018 at 8:38:41 AM UTC-6, Damon Zhao wrote:
>
>
> Your visitor pattern here seems to not be a "visitor" pattern. I would
> think that the Go equivalent would define an interface, and visit based on
> that interface.
Here’s what the Wikipedia article says:
In essence, the visitor allows adding new virtual functions to a family of
> class
I went ahead and opened a Go 2
proposal: https://github.com/golang/go/issues/23725
Thanks,
Matt
On Tuesday, February 6, 2018 at 3:26:15 PM UTC-6, matthe...@gmail.com wrote:
>
> What do you mean by a "slice pointer key" ?
>
>
> map[*[]Something]string
>
> Then map consumers can do key comparison
>
> What do you mean by a "slice pointer key" ?
map[*[]Something]string
Then map consumers can do key comparisons. I originally used this for an
unordered set type.
Matt
On Tuesday, February 6, 2018 at 11:12:06 AM UTC-6, rog wrote:
>
> On 6 February 2018 at 14:55, > wrote:
> > Slice point
Slice pointer keys are another option but that concept is tricky too.
Matt
On Tuesday, February 6, 2018 at 3:34:54 AM UTC-6, rog wrote:
>
> ... tick, tick, tick, tick... dide-dudi-diddlidedum...di!
>
> func comparable(xs []int) interface{} {
> type elem struct {
> first
They haven’t seemed necessary in small application development. I'll
monitor for real-world examples.
There's a few repositories for Go design patterns:
https://github.com/tmrts/go-patterns
https://github.com/monochromegane/go_design_pattern
https://github.com/yksz/go-design-patterns
But they
You need the package name.
var a *common.Any
Matt
On Saturday, February 3, 2018 at 10:45:22 AM UTC-6, l vic wrote:
>
> I am trying to alias empty interface in one package so it could be used in
> several other packages:
> in "myproject/common/common.go"
>
> package common
>
> type Any interface
I think learning the detail of these Go constructs by transliterating OOP
design patterns is good value. For example, above I mention being surprised
to learn that a method will override an embedded struct’s function field
with the same name. This may be useful for writing minimized Go code in
>
> Are you sure that's the only edge-case? Because this thread is kinda long
> and there might even be things we are not thinking about.
In the original discussion above I see one opinion toward comparing headers
and four toward by element values (like strings). I didn't see any
additional
Here’s my proxy example with “func (a ProxyCar) Drive()” instead of
DriveCar (I didn’t think this would work), and an F-150:
https://play.golang.org/p/drDDkx_e0Mp
This may fix the signature difference but I see that having an interface
type like you suggested for car would allow other data and
I’m looking at patterns summarized on Wikipedia from “Design Patterns:
Elements of Reusable Object-Oriented Software” and writing out a few as the
equivalent in Go.
Visitor: https://play.golang.org/p/A5tNzxMmetH
Abstract Factory: https://play.golang.org/p/SWwuX49eysd
Factory Method: https://pl
>
> Transaction can give an error for different reasons, and I want to give
> the client a wide choice. Probably, the financial features are to blame for
> this ...
I agree with having switchable errors but usually this is done with vars of
types that implement the error interface. For exampl
For issue tracker reports these questions are asked:
What did you do?
What did you expect to see?
What did you see instead?
Please describe your API needs in more detail. Interfaces are useful for
API design but it appears we may be misunderstanding what your interface
type assertion needs ar
Hi Eduard, here’s a code review.
Usually on GitHub the license is in LICENSE, not LICENSE.md.
core_public.go, transaction_public.go could just be core.go and
transaction.go.
The Core type is a code smell to me because it doesn’t represent anything
specific. Perhaps there’s a need for multiple
Converting []tmpType to []Useable: https://play.golang.org/p/u3WUOEopku9
I'm not sure I understand, but if you can make an exhaustive list of
possible input slice types and an element can assert to Useable then the
elements can be copied into a []Useable.
Matt
On Wednesday, January 31, 2018 at
Go files are usually encoded UTF-8, what text encoding is the terminal
using?
Matt
On Wednesday, January 31, 2018 at 7:45:04 AM UTC-6, wangdach...@gmail.com
wrote:
>
> This is my first posted,Thank you for helping me solve this problem
>
> my oprate-system is windows 10
>
> goland version is 20
Here's a proposal covering this: https://github.com/golang/go/issues/21114
Matt
On Wednesday, January 31, 2018 at 2:58:15 AM UTC-6, Egon wrote:
>
> Use govet and see https://golang.org/cmd/vet/#hdr-Shadowed_variables...
> Of course, there are more tools that can help you
> https://github.com/al
I agree with you Axel. One point is that allowing struct comparison but not
slice comparison was counterintuitive to me at first.
What about a proposal addition of “types with self-references in slices
cannot be compared”?
While comparison by header versus comparison by value may not be an obvi
Correction on the self-reference example:
a0 := A{}
// equal
a1 := A{a0, A{}}
a1[0] = a1
a2 := A{a1, a1[1]}
// not equal
a3 := A{A{a1, a1[1]}, a1[1]}
Thanks,
Matt
On Tuesday, January 30, 2018 at 5:19:44 PM UTC-6, matthe...@gmail.com wrote:
>
> - When slices can be compared, they can be used as m
>
> - When slices can be compared, they can be used as map keys. What happens
> if the contents of a slice are changed after it has been added to a map?
I’m not too familiar with Go map internals, but my thought is the key hash
would depend on the backing array values. Go maps also allow read
Here’s a draft for a Go 2 proposal that I’d like to add to the issue
tracker since there’s no discussion there about this:
Slices should have equality defined.
https://golang.org/doc/faq#map_keys
Map lookup requires an equality operator, which slices do not implement.
> They don't implement eq
The blog post is the open source roadmap: https://blog.golang.org/toward-go2
There are over 200 Go 2 proposals and a third of them have been closed:
https://github.com/golang/go/issues?q=is%3Aissue+is%3Aopen+label%3AGo2
The community is collecting and discussing ideas there. Some contributors
a
Dave talks about map representation here:
https://dave.cheney.net/2017/04/30/if-a-map-isnt-a-reference-variable-what-is-it
I don’t understand why you need a pointer to a map, can you provide a code
example?
Matt
On Tuesday, January 30, 2018 at 8:22:54 AM UTC-6, Trig wrote:
>
> Appreciate the r
Thanks for sharing gradboostreg here.
Matt
On Tuesday, January 30, 2018 at 12:47:33 AM UTC-6, Sina Siadat wrote:
>
> Hi Matt,
>
> Thank you for the code review!
>
>
>
> > gradboostreg/tree, stat, sample have no tests.
>
> Yes, thanks for reminder, I should write tests for them!
>
>
>
> >
>
> I agree even though I've never thought like this. For my own curiosity,
> what gain do you see by embedding structs like this?
Now when making calls you don’t have to refer to the field to call the
methods; the embedded type’s methods are promoted to the struct type but
still use the fiel
Hi Sina, here’s a general code review.
gradboostreg/tree, stat, sample have no tests.
These sub-packages may be better in package gradboostreg since they seem
straightforward and contained to this library. Keeping those things in
sub-packages doesn’t seem to add much value over just having sepa
Hi Quentin, here’s a code review.
Since type ability is not exported, why not embed sync.Mutex? What does o
stand for?
I’d say that comments like “// newAbility creates a new ability” are
unnecessary. The identifiers are documentation. There are many unnecessary
comments.
For read-only method
Can you describe your performance needs in more detail?
I missed the need for the struct values in the copy (obviously needed to
encode to JSON). Going back to locks for a moment, my thought now is that a
sync.RWMutex on this map would have an RLock taken by every struct
read/write and then the
Hi Keith,
Can you share some specific things you’d like to see already implemented?
Serving JSON data and web pages to a browser seems like a straightforward
project with the standard library examples and resources available with
Internet search engines.
Here’s an official net/http server walk
>
> Interesting. Does this work on all browsers on all platforms?
Untested here. I've seen it work on macOS with Safari, Chrome, and Firefox.
The || is to support how different browsers indicate a back button press /
back cache load.
Matt
On Saturday, January 27, 2018 at 3:49:19 PM UTC-6, P
Hi Jeeva,
Thanks for sharing go-resty here. I’d like to mention that my input about
struct embedding may not be valid. It was pointed out to me previously when
I made a similar suggestion that in library design embedding exports all of
the embedded type’s methods, so you may have those named fi
Why not this?
type StructMap map[string]*SomeStruct
type SyncStructMap struct {
*sync.Mutex // maybe change to *sync.RWMutex if there are mixed
read/write synced operations
StructMap
}
func (a SyncStructMap) Copy() StructMap {
out := make(StructMap)
a.Lock()
for key, value :
Here's where I've gotten with custom user authentication, this may be a
starting point for some
people: https://gist.github.com/pciet/8529531fffbe8d9523d883c901d311da
Matt
On Thursday, January 25, 2018 at 4:40:29 PM UTC-6, Jeff Goldberg wrote:
>
> On Jan 25, 2018, at 2:58 PM, Pat Farrell >
> w
>
> Specific question: how do you handle the user hitting the "back" button on
> their browser? Its very common and a lot of simple approaches don't handle
> it well.
This was a problem for me. I force the page to reload instead of using the
cache:
//
https://stackoverflow.com/questions/8
Hi Jeeva, here’s a code review.
In client.go *Client R() the creation of the *Request unnecessarily sets
zero values for fields. They could just be omitted instead. Same in
default.go at func createClient.
The Client type could have *log.Logger and http.Header embedded in the
struct instead of
Here’s a third vote for the standard library.
https://golang.org/pkg/net/http/ + https://golang.org/pkg/html/template/
are already effectively a web framework.
Matt
On Thursday, January 25, 2018 at 3:15:25 AM UTC-6, Florin Pățan wrote:
>
> Big plus one for Buffalo. Out of the frameworks I've se
> (2) would using a session cookie + some authorization middleware (such
as casbin) make sense for our situation? what are its pro's and con's?
This is what I'm familiar with. The main con is having to check the
authorization in every request. Writing your own isn't complex.
Matt
On Thursday,
Normally a web browser would lose the initial cookie value. I think you may
be misunderstanding the use of the gorilla/sessions library (I did even
after inspecting the documentation and source code for awhile). The point
is to store arbitrary values in a store, not provide any form of
authenti
Hi Clinton,
Here's an example for the struct of function
approach: https://play.golang.org/p/F_f0hLNsmSW
These are not key issues, I'm just sharing the path I've been on.
Thanks for sharing Graven here. I'll read those references.
Matt
On Wednesday, January 24, 2018 at 3:57:27 PM UTC-6, matth
You are using interfaces to define a type. The overhead of interface isn’t
necessary to achieve the same goal. I see that github.com/gorilla also uses
this pattern in places. Supporting another tool or providing a mock for
testing is just making a new value of the type.
I do use sub-packages an
One way is the server still serves all of those endpoints, but instead of
returning a full HTML page they each just return data. The single page
state depends on what data is received when each is queried. Using a
template for the single page is a way to set an initial state.
jQuery has easy to
My previous advice may have been misunderstanding the library, I haven’t
used it before although I have done sessions before.
What’s happening in this example is the "authenticated" bool is encoded
into the cookie value. The proper way to call logout is to take the cookie
set in logout (which e
I don’t have an example but a concurrent solution seems straightforward to
reason about. Here’s a description of where I’d start:
Perhaps have a type to send on the buffered chan from the one producer
goroutine?
type Chunk struct {
Index int
Data []byte
}
Then make any number of worker go
Since store.Get may silently make a new session I would first verify the
session key gotten in the logout handler matches what you sent in the
cookie. Maybe try -i on the logout curl call?
Matt
On Tuesday, January 23, 2018 at 8:51:40 AM UTC-6, aiki...@gmail.com wrote:
>
> I was working with the
The references in the Wikipedia article have a lot of overview detail:
https://en.wikipedia.org/wiki/Go_(programming_language)#Concurrency:_goroutines_and_channels
I’m not convinced Node.js or Go are inherently more efficient than
multithreading. Due to the overhead of repeating operating system
I assume you know where your interface{} will no longer be used. Why not
put in an explicit optimization structure delete there? There's already a
New, make a Done or something like that.
Matt
On Sunday, January 21, 2018 at 6:41:00 PM UTC-6, simon place wrote:
>
> after a bit of thought, its no
The higher priority -19 we're interested in has the Permission denied error
message, the command needs to be run with elevated OS privileges. Is
waf-client the program that has the real-time requirement?
If you separate the calling process out to a separate computer do you still
see the delay?
Have the closure generator return the resource?
https://play.golang.org/p/16pyo0gh8_s
I'm not sure what you mean by using types instead, or even why you are
trying to do this. Can you explain more?
Matt
On Sunday, January 21, 2018 at 3:17:20 PM UTC-6, simon place wrote:
>
> i wrote the code be
Bytes has one too: https://golang.org/pkg/bytes/#Compare
Matt
On Sunday, January 21, 2018 at 12:59:21 PM UTC-6, Arie van Wingerden wrote:
>
> https://golang.org/src/strings/compare.go
>
> 2018-01-21 14:42 GMT+01:00 Peng Yu >:
>
>> Hi, cmp() in python can return three values -1, 0, 1. Is there a
>
Sounds good to me. I'm not familiar with any performance tradeoffs like
branch prediction changes, but I assume the compiler result is equivalent.
func CmpX(x, y X) int {
if x == y {
return 0
}
if x < y {
return -1
}
return 1
}
Matt
On Sunday, January 21, 201
Hi Clinton, here’s a code review.
Does BuildTool need to be an interface? Having methods on a pointer to
nothing (type GoBuildTool struct{}) seems unnecessary to me. Also, why not
have this at the level of package main?
Same with graven/commands, graven/config, graven/domain, graven/util, since
There isn’t a standard library or built-in function that does both a
comparison and less operation.
For best performance you would write it for your type. For best generality
you would write a library function that takes two interface{} values and
converts them to the comparable types that work
Opening an issue at https://github.com/golang/go/issues should get the
change in.
Matt
On Saturday, January 20, 2018 at 11:16:56 PM UTC-6, Glen Huang wrote:
>
> Thanks for the reply.
>
> Hopefully the doc can be changed to avoid confusion.
>
> On Sunday, January 21, 2018 at 1:16:04 PM UTC+8, Ian
range on slices seem similar. The loop has the current index so looking
ahead, behind, or reslicing is convenient.
>From https://golang.org/ref/spec#For_statements:
For an array, pointer to array, or slice value a, the index iteration
> values are produced in increasing order, starting at eleme
Looking at popular Go repositories on github may be a good
source:
https://github.com/search?l=Go&o=desc&q=golang&s=stars&type=Repositories&utf8=%E2%9C%93
Matt
On Friday, January 19, 2018 at 7:56:33 AM UTC-6, Chris Hopkins wrote:
>
> Agreed.
> I found the standard library and ioutil in particul
It looks like MacOS had CPU PM options removed from pmset in the last few
years, so I’m not sure it’s possible to disable in recent versions. On
Ubuntu I was able to get cpufrequtils to work a few months ago:
https://askubuntu.com/questions/523640/how-i-can-disable-cpu-frequency-scaling-and-set-
The contributors are explorable
here: https://github.com/golang/go/graphs/contributors
Matt
On Thursday, January 18, 2018 at 12:42:03 PM UTC-6, Jan Mercl wrote:
>
> On Thu, Jan 18, 2018 at 7:28 PM Davor Kapša > wrote:
>
> > How many members has core team?
> >
> > How are they internally organi
Is your test request source running on the same computer? Have you disabled
OS power management features?
Matt
On Thursday, January 18, 2018 at 10:23:43 AM UTC-6, sotte...@gmail.com
wrote:
>
> I developed an RPC Service with high requirements for real-time
> performance. There was an unexpecte
For Go 2 I mentioned adding multiple cases or fallthrough for select
here: https://github.com/golang/go/issues/23196
Matt
On Thursday, July 11, 2013 at 12:52:15 AM UTC-5, Johann Höchtl wrote:
>
> On 10.07.2013 22:50, Rob Pike wrote:
> > As far as the select is concerned, what you have is right.
To me having packages in an application is already a code smell, my
requirement is each non-main package should provide very specific
functionality that could be shared between applications.
I remember the Quake source code having most everything in one directory of
C files, and I think Go appl
My understanding is that when something is assigned to an interface the
thing is copied. Maybe the swap is causing a copy of the interface contents?
I'm not sure what Xcode does but pprof and package testing benchmark are
more common. For benchmarking be sure to disable power management features
If you use struct embedding I think you may get what you are looking for:
type retryResponseWriter struct {
http.ResponseWriter
attemptsExhausted bool
}
Now retryResponseWriter has all of the methods of the http.ResponseWriter
you assign to it and can be cast to those http interfaces wit
Here's an experience report on teaching new programmers with
Go: http://www.monogrammedchalk.com/go-2-for-teaching/
On Tuesday, January 16, 2018 at 8:42:34 AM UTC-6, matthe...@gmail.com wrote:
>
> From my experience:
>
> Expecting somebody at 0 to become a software engineer via coursework or a
>
The type switch may not work since these http types are interfaces that may
all be satisfied by the ResponseWriter. Instead of a type switch you would
need to do a type assertion for each possible http interface.
Matt
On Tuesday, January 16, 2018 at 9:01:28 AM UTC-6, matthe...@gmail.com wrote:
Can you provide some example code showing the problem?
I don’t understand why you are wrapping the ResponseWriter. If you need to
pass along metadata then wrapping makes sense, but why not just pass the
original interface and do the type switch in each handler?
type RetryResponseWriter struct {
>From my experience:
Expecting somebody at 0 to become a software engineer via coursework or a
book doesn’t seem reasonable to me. There’s at least a couple years of
mentorship and experience required just for the baseline.
JS or Go can get you far without knowing about stack traces, processor
Another benchmarking rule is the operating system may be dynamically
adjusting performance for power saving or other reasons. Be sure to disable
any such features before running the benchmark.
Matt
On Monday, January 15, 2018 at 9:04:11 AM UTC-6, Jesper Louis Andersen
wrote:
>
> General rules:
Use the interface type assertion or type
switch: https://tour.golang.org/methods/16
Matt
On Sunday, January 14, 2018 at 5:01:39 AM UTC-6, Jan Mercl wrote:
>
> On Sun, Jan 14, 2018 at 5:37 AM > wrote:
>
> > I have a parent/child class ...
>
> You don't. No classes, no parents, no children. You ne
This works:
b, a := 1, struct{ x int }{2}
But this doesn’t:
var a struct{ x int }
b, a.x := Returns1And2()
But this does:
var a struct{ x int }
var b int
b, a.x = Returns1And2()
And this does:
var a int
b, a := Returns1And2()
Matt
On Tuesday, January 9, 2018 at 5:59:49 PM UTC-6, Kevin Mala
Not exporting the mutex and other fields is a good consideration and
probably does apply here. I'll keep that in mind.
Thanks,
Matt
On Tuesday, January 9, 2018 at 12:15:55 AM UTC-6, Jakob Borg wrote:
>
> On 8 Jan 2018, at 23:35, matthe...@gmail.com wrote:
>
>
> sync.RWMutex works well as an emb
Here’s a code review:
sync.RWMutex works well as an embedded struct field. Locking DB could be
db.Lock() instead of db.mu.Lock(), and the same could apply to other fields.
type DB struct {
sync.RWMutex
…
type Options struct {
BackgroundSyncInterval time.Duration
fs.FileSystem
}
See
This looks concurrency safe to me too. Here's style suggestions:
Instead of
type memoryCache struct {
Data map[string]string
mux sync.Mutex
}
You could have
type memoryCache struct {
Data map[string]string
*sync.RWMutex
}
func (c memoryCache) Set(key string, val string) {
defer c.Unlock
Why avoid using a bigint column storing cents?
Matt
On Sunday, January 7, 2018 at 9:29:51 AM UTC-6, evan wrote:
>
> c# has a decimal type that i can map my numeric(12,2) column data type to,
> but golang doesnt have a decimal type.
>
> i'm trying to avoid storing money values as cents then conve
I like the C if one-liner without curly braces but that doesn't apply to Go
since the if condition isn't in parenthesis.
if (exists == false) i++;
I've never liked the non-braces version of if when across multiple lines.
In JavaScript I've started always writing out if like in Go and will
prob
“The Food and Drug Administration Safety and Innovation Act (FDASIA),
signed into law on July 9, 2012, expands the FDA’s authorities and
strengthens the agency's ability to safeguard and advance public health…”
The FDASIA doesn’t seem to have a direct effect on this project, although
they do de
From
https://www.pharmamanufacturing.com/experts/contract-manufacturing-management-supply-chain-management-/show/71/
In the US: Food and Drug Administration Safety and Innovation Act (FDASIA),
Drug Supply Chain Security Act (DSCSA)
Don mentions the term "end-to-end security program".
Here's a
Using a channel read in the http handler will block the ticker for loop
until the read occurs, but if you want that then pass mc into the generic
function: https://play.golang.org/p/GrHQxPhy1qu
Using a buffered channel will keep the history of ticks and not block but
may run out of buffer space
Can you have the client make concurrent periodic get requests that return
the current status?
Alternatively websockets (https://github.com/gorilla/websocket) may work
depending on your deployment needs (Google App Engine doesn’t support them
yet and old web browsers don’t support them).
Matt
Here’s an overview of what I’ve done, but no quality claim is made.
In package main there’s a global:
type DB struct {
*sql.DB
}
var database DB
In func main() I call an initialization function that reads a JSON
configuration file and does sql.Open with dbname, user, password, host,
port,
101 - 200 of 244 matches
Mail list logo