Re: [go-nuts] Re: Range over int

2024-02-22 Thread Henry
This is one feature that provides little value beyond saving a few keystrokes and looking slightly nice, but with potential of increased complexity when we need to implement more important features to the language down the road. This is my opinion. It shouldn't have been added, but what was

Re: [go-nuts] Go 1.21 new builtin function clear()

2023-07-06 Thread Henry
uiltins that do > different things, but there is precedent. > > On Thu, Jul 6, 2023 at 8:14 AM Axel Wagner > wrote: > >> On Thu, Jul 6, 2023 at 7:49 AM Henry wrote: >> >>> So, if I get this right, clear on map will result in map length equals >>> t

Re: [go-nuts] Go 1.21 new builtin function clear()

2023-07-05 Thread Henry
So, if I get this right, clear on map will result in map length equals to zero, but clear on slice is only a value-zeroing operation and the slice length remains unchanged? They seem like two different operations to me. I don't think that built-in clear function is necessary. It doesn't seem

Re: [go-nuts] [RFC] Yet another proposal for Go2 error handling

2023-07-03 Thread Henry
I don't think it has anything to do with motivation, Mike. The problem I see is that there is no good enough solution that offers a substantial benefit over the current approach. Many error handling proposals involve rearranging the code with a few line savings, and sometimes at the cost of

Re: [go-nuts] Re: 'go run hello.go' taking ~30 seconds on windows

2023-06-22 Thread Henry
I am running Windows 11 with Kaspersky. I don't have such problems. When it comes to Windows, it isn't as simple as blaming your AV. Windows is a complex OS and it is doing many different things in the background (e.g. doing maintenance, installing updates, etc.). You should open your Task

[go-nuts] Re: Non-method funcs

2023-03-27 Thread Henry
functions and sometimes it doesn't. Henry On Monday, March 27, 2023 at 9:05:16 PM UTC+7 nc wrote: > Hello, > > I have found that I have a tendency to try to code non-method funcs in a > pure way (functionally speaking - so that the caller will not modify any of > its

[go-nuts] Re: maybe the best practice for worker pool scheduler, need review my code

2023-02-21 Thread Henry
Go's goroutine is a thread pool. It maps M tasks over N threads. It has its own scheduler, etc. It reuses threads and avoids the overhead of unnecessary thread creation. I don't understand why you need to create a pool on top of another pool. On Saturday, February 18, 2023 at 11:43:57 PM UTC+7

[go-nuts] Re: 'go run hello.go' taking ~30 seconds on windows

2022-12-15 Thread Henry
Assuming that it is a basic Hello World program, I don't have such problems on my Windows 11 laptop and like many Windows machines, it has antivirus, etc. running. I think it could be something specific to your machine or environment. On Thursday, December 15, 2022 at 2:11:48 PM UTC+7

Re: [go-nuts] Practical use cases of recover in golang

2022-10-09 Thread Henry
You may want to make your app more robust by handling panic in the topmost layer of your application. With many people working on the code and various external dependencies, it is often impractical to ensure none of the code panics. This is where recover comes in. On Monday, October 10, 2022

Re: [go-nuts] Is Go a security malware risk?

2022-08-23 Thread Henry
Should a knife maker be held liable and required to 'fix' their knives when their knives are used in criminal acts? If the knives are made specifically with the sole purpose of breaking the laws, then yes, the knife maker should be held liable. If the knives are general purpose tools, then no,

Re: [go-nuts] Preemptive interfaces in Go

2022-08-10 Thread Henry
0 CRs to get Go *readability* (compared to 4 months and 3 CRs > for Python). > > On Tuesday, August 9, 2022 at 1:08:42 PM UTC-7 bse...@computer.org wrote: > >> On Tue, Aug 9, 2022 at 1:52 PM Tim Peoples wrote: >> >>> Yeah, I'm with Burak on this one. The int

Re: [go-nuts] Preemptive interfaces in Go

2022-08-08 Thread Henry
I am sure that many of us have been on that journey. After using Go for some time, we discover some practices that are not necessarily in agreement with the existing "adages" but effectively solve our problems. For me, if the data type is mutable, I prefer returning interfaces. It would be

[go-nuts] Re: Using generics to solve Optional argument problem for multiple methods

2022-07-27 Thread Henry
``` type WithSharedOption interface { SomeMethod() } type OptionA struct { } func (a OptionA) SomeMethod(){} type OptionB struct { } func (b OptionB) SomeMethod(){} //without generics func WithShared(option WithSharedOption){} func WithANotShared(option OptionA){} //with generics func

Re: [go-nuts] Will Go be discontinued?

2022-07-26 Thread Ehioje Henry Erabor
This should be a big joke right? On Tue, Jul 26, 2022 at 6:53 AM Amnon wrote: > > On Monday, 25 July 2022 at 19:48:24 UTC+1 Carlos Jimenez wrote: > >> I think it will be discontinued soon >> The average lifespan of a discontinued Google product is *4 years and 1 >> month*. so should be a matter

[go-nuts] Re: Quick poll: Which of these declarative UI trees looks the most legible to you?

2022-06-08 Thread Henry
Alternatively, you may experiment using structs with exported fields. It may be a bit less verbose. On Thursday, June 9, 2022 at 8:28:32 AM UTC+7 atd...@gmail.com wrote: > Hey, > > Yes, they all look kind of similar because they all use function > composition and are variations of the same

[go-nuts] Re: How to call function from struct in slice?

2022-06-04 Thread Henry
I have no idea what problem you are facing. Your example is not clear enough to me. I think you may have several other problems in the mix as well (such as calling code from another package, etc.). Try reading the compiler error and see if it helps. I have included a more elaborate example.

[go-nuts] Re: How to call function from struct in slice?

2022-06-03 Thread Henry
You need to cast the generic interface{} to its appropriate type. For instance: ``` modules := CompileModules() for _, module := range modules { mod, ok := module.(*AddModule) if !ok { //error handling if module is not of type AddModule }

[go-nuts] Re: Functions vs Methods: explain reasoning behind STD

2022-06-03 Thread Henry
I think after a while people tend to come up with their own best practices when using Go. Each person has their own preference. There is really no right or wrong here. The argument for method vs function usually comes down to the domain and which makes more sense. For my own 'rules', I prefer

[go-nuts] Re: Java to Go converter - 2

2022-05-17 Thread Henry
Kudos to you. Java to Go is a lot of work. Java is a more complex language. It has more features and more possibilities for expressing the same model/algorithm. You need to identify all these possibilities, parse, and convert them to Go. I could be wrong about this, but it may be easier to

[go-nuts] Re: Golang and virustotal

2022-05-14 Thread Henry
I use Windows and Kaspersky. I build Go from source. I don't have such problem. On Saturday, May 14, 2022 at 2:59:09 AM UTC+7 Amnon wrote: > My workaround is not to use Windows. > And not to use anti-virus programs that thing all Go programs are viruses. > > On Friday, 13 May 2022 at 16:21:31

[go-nuts] Re: Tacit Golang?

2022-04-01 Thread Henry
Something like this? https://play.golang.com/p/rhu9PX9GSbp On Saturday, April 2, 2022 at 5:41:52 AM UTC+7 sam.a@gmail.com wrote: > Point-free programming, or "tacit programming", is a convention that > highlights the intent without syntactic noise. > > For those unfamiliar, wikipedia: >

[go-nuts] Re: Is it possible to change the existing printline dynamically in golang?

2022-04-01 Thread Henry
You can use the ansi escape code if the target terminal supports it. Alternatively, you can use the carriage return '\r' and reprint the line. Note you may need to overwrite with empty space to delete the line before rewriting it. On Friday, April 1, 2022 at 12:38:37 PM UTC+7

Re: [go-nuts] Re: autoremove unviolated precondition checks at compile time

2022-03-31 Thread Henry
You only need to validate in Mul and Add. They are the ones that work directly with the slices and know the reason behind such requirements. Muladd only needs to check for any error returned by either Mul or Add. In the future, if the requirement changes in either Mul or Add, you don't need to

[go-nuts] Re: autoremove unviolated precondition checks at compile time

2022-03-30 Thread Henry
You will need a build tag for that. For example: In a separate file, define the build tag ``` // +build debug package mypkg func init() { Debug = true } ``` Then, in other files, use the tag ``` package mypkg var Debug bool func DoWork() { if Debug { // perform validation } }

Re: [go-nuts] Looked at using Go ... nil/SEGV really bothered me .. Go2 Proposal?

2022-03-24 Thread Henry
It is good practice for a function to validate the values it receives from outside, whether they are function arguments or return values from other functions. It is not just a nil check, but a proper validation. I don't think that automated nil check can replace proper validation. Sometimes

[go-nuts] Re: Is there a way to eliminate the code repetition in the code?

2022-03-21 Thread Henry
Perhaps something like this? ```go func Convert[T, A any](src []T, converter func(T) A) []A { result := make([]A, len(src)) for index, a := range src { result[index] = converter(a) } return result } ``` See https://play.golang.com/p/rq89Wposc-D On

[go-nuts] Re: Constrain a type to be either a slice or a map

2022-03-18 Thread Henry
ew("invalid type") } return value.Len(), nil }, } } ``` On Friday, March 18, 2022 at 5:47:29 PM UTC+7 RussellLuo wrote: > Thanks for your reply, Henry! > > I admit that my problem seems a little bit silly without providing > the contextual informati

[go-nuts] Re: Constrain a type to be either a slice or a map

2022-03-18 Thread Henry
Have you considered this? ```go func IsBetween(value, min, max int) bool { return value>=min && value <=max } if IsBetween(len(myMap), 10, 25) { //do something } ``` On Friday, March 18, 2022 at 11:20:37 AM UTC+7 RussellLuo wrote: > Hi there, > > Thanks to Go generics in 1.18, I can write

Re: [go-nuts] Why is it forbidden to add methods to an existing type?

2022-03-17 Thread Henry
My own preference is to have a small number of methods and put the general functionalities into functions. By putting the general functionalities into functions, you allow code reuse. In object-oriented programming, you normally attach as many functionalities as possible to their corresponding

Re: [go-nuts] Why, oh why, do people do this? Things that annoy me in Go code.

2022-03-07 Thread Henry
Naming things is one of the hardest things a programmer needs to do. Seriously. On Tuesday, March 8, 2022 at 6:08:09 AM UTC+7 ba...@iitbombay.org wrote: > GoBOL, anyone? > > > On Mar 7, 2022, at 2:20 PM, Rob Pike wrote: > > > > It could have been > > > > interface >

[go-nuts] Re: Generic integer math limitation

2022-02-08 Thread Henry
I don't understand what your function is trying to accomplish, but you know you can break down 512 into smaller numbers, right? For instance, i / 512 is equivalent to (i / 64) / 8. Do remember that integer cannot hold fractions. In the case of uint8/int8, the result is always zero. If you

Re: [go-nuts] Re: Why, oh why, do people do this? Things that annoy me in Go code.

2022-01-30 Thread Henry
eed to be broken down further. On Sunday, January 30, 2022 at 9:24:15 PM UTC+7 Brian Candler wrote: > On Sunday, 30 January 2022 at 11:31:25 UTC Henry wrote: > >> In Go, there is only one looping construct, which is the "for" keyword. >> > > Don't forget "g

Re: [go-nuts] Re: Why, oh why, do people do this? Things that annoy me in Go code.

2022-01-30 Thread Henry
Comments are useful to communicate what is not already apparent in your code. Sometimes comments may help you find bugs in your algorithms. On the other hand, keep your comments terse and not longer than what is necessary. Respect other people's time. Long names are not necessarily better. It

[go-nuts] Re: Alternatives to wrapping errors

2021-12-31 Thread Henry
The purpose of error wrapping is to give contextual information about the error. It is supposed to help you understand and locate the error. For instance, *"invalid filename"* is not particularly useful when compared to *"fail to load customer data: invalid filename"*. Error wrapping is a

Re: [go-nuts] Will the generics support be enabled by default in Go 1.18?

2021-10-14 Thread Henry
I thought that hiding generics behind a flag is already a thing in Go 1.17? If a feature is solid enough for stable release, don't make it an opt-out. People can just avoid the language features they don't want to use. I disagree with the suggestion of adding stuffs to go.mod to enable or

[go-nuts] Re: Coverage Reports

2021-08-23 Thread Henry
See https://kenanbek.medium.com/go-tests-with-html-coverage-report-f977da09552d On Saturday, August 21, 2021 at 3:26:41 AM UTC+7 ivan.rosal...@gmail.com wrote: > Hi, > > > > Anybody knows how I can get a coverage report, ever if the > unit test was failed, when run go test

Re: [go-nuts] What's going on while using "append" in memory?

2021-08-09 Thread Henry
Just sharing some tips. When working with slices, it is often a good idea to lend a helping hand to the compiler. Don't declare something like this, unless you have no other choices. ``` var slice []int ``` If you know the data right away, you can do something like this: ``` slice :=

Re: [go-nuts] What's going on while using "append" in memory?

2021-08-08 Thread Henry
Append is for appending items at the end of a slice. If there is enough space, Go will simply append the items and return the slice. If there is not enough space, Go will create a new slice with double the capacity of the existing slice or at least enough space to hold the new items (whichever

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-28 Thread Henry
On Wednesday, July 28, 2021 at 3:05:43 PM UTC+7 amits...@gmail.com wrote: > That sounds interesting - is the tool generating or is able to > generate SQL for different databases? That must have been a pretty big > effort to create such an abstraction. > > It produces different SQL for

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Henry
'm interested to know if you tool is open-source? Thx! > > > Le mar. 27 juil. 2021 à 11:49, Henry a écrit : > >> We go-generate the mapping between the data models and the database. It >> was tedious to write such tool, but it was a time well spent. Now we just >> work w

Re: [go-nuts] Re: What are the options to fake SQL database for testing?

2021-07-27 Thread Henry
We go-generate the mapping between the data models and the database. It was tedious to write such tool, but it was a time well spent. Now we just work with data models and not worry about testing the SQL instructions. Occasionally, we use SQLite in-memory database to double-check certain

[go-nuts] Re: How to Optimize A Golang Application Which Has More Than 100 Million Objects at Peak?

2021-07-16 Thread Henry
Given your description about being CPU intensive and all, I am guessing you may have created those objects inside your busy loop. Try moving those objects out of the loop and reuse them. Another option is to use sync.Pool. As for tools, try pprof: Profiling Go Programs - The Go Blog

Re: [go-nuts] UML && Golang, part 2 ?

2021-07-05 Thread Henry
UML is a design language. You can use it to express ideas and concepts regardless your programming languages, and to communicate those ideas to other people. Just like any other tools, you can use it in your projects as you see fit. Many people have moved into a more agile-like development

Re: [go-nuts] Representing Optional/Variant Types Idiomatically (or not)

2021-06-19 Thread Henry
Instead of exposing the fields in a struct like that, you may consider using constructor function to have better control over what the user can set into the struct. That way you don't need to worry about the user setting invalid values. For instance, ```Go type EmailEvent struct{ id string

Re: [go-nuts] Re: Give us const arrays please :)

2021-04-12 Thread Henry
Thanks for the information. I did not know that. It's good to learn something new. :) On Monday, April 12, 2021 at 7:17:05 PM UTC+7 wagner riffel wrote: > On Mon Apr 12, 2021 at 5:04 AM -03, Henry wrote: > > The example you gave is actually a map[rune]bool in Go, and not an >

[go-nuts] Re: Give us const arrays please :)

2021-04-12 Thread Henry
The example you gave is actually a map[rune]bool in Go, and not an array. I don't think C's array work like that too. I think you are confusing Go with other languages. In addition, arrays are rarely used in Go. Many people prefer using slices. On Monday, April 12, 2021 at 6:33:47 AM UTC+7

Re: [go-nuts] promoted methods confusion

2021-02-22 Thread Henry
I think the problem is that people try to use embedding in place of inheritance. You can see that in the original author's example involving Cat, Animal, and Pack. Embedding shares many similarities to inheritance, such as method promotion, but they are not the same. Embedding is in a way more

Re: [go-nuts] Error handling

2021-02-17 Thread Henry
I actually prefer the explicit error handling: ``` f, err := os.Open("path") if err != nil { //handle error } ``` When you are reading the code to look whether a certain condition has been handled, the explicit branching statement makes it easier to scan. On Wednesday, February 17, 2021 at

[go-nuts] Re: Interface Fields

2021-01-12 Thread Henry
, since PrintID requires only the ID field, you can refactor it into something like this: ``` func Print(str string) { fmt.Println(id) } Print(x.ID) Print(y.ID) ``` I hope it helps. Henry On Wednesday, January 13, 2021 at 8:34:00 AM UTC+7 Dave Protasowski wrote: > I'm doing some due-dilige

Re: [go-nuts] Generics - please provide real life problems

2021-01-01 Thread Henry
I share some of the OP's concerns. At the moment, I am horrified at the syntax of some of the more advanced generics examples in the proposals, particularly when you throw contracts, methods and stuffs into the mix. There are just way too many brackets to my liking. In a typical IDEs, they use

Re: [go-nuts] Let Go also support manual memory management, a good or bad idea?

2020-11-16 Thread Henry
There is a very little performance benefit to manual memory management with today's hardware. Someone mentioned games earlier. Many games are written in languages with GC. C# and Java are among the most popular languages for game development. A number of games are written in C++ but many

[go-nuts] Re: Proposal: New keyword returnif (resolves error handling)

2020-11-11 Thread Henry
Verbose error handling has its own merits. It is easier to scan, particularly when you are looking whether you have handled certain cases. It may be repetitive to write, but it is easy to read and it stands out. In a language that offers multiple ways to handle an error, you have to slow down

Re: [go-nuts] Go is easy to lean. But other languages are hard to forget

2020-10-05 Thread Ehioje Henry Erabor
I believe all these are statements of facts based on practical observations that one finds out that to learn GO one needs to unlearn and then learn again. For GO, that is indeed the way to GO. On Mon, Oct 5, 2020 at 12:21 AM Tyler Compton wrote: > I wonder if mailing lists for all languages get

Re: [go-nuts] Re: How to print arrays with commas and brackets

2020-08-07 Thread Henry
upon the given solution and tailor it to his/her needs, and whether the OP would like to escape certain characters or format it in any other way. On Saturday, August 8, 2020 at 9:53:09 AM UTC+7, Kurtis Rader wrote: > > On Fri, Aug 7, 2020 at 7:46 PM Henry > > wrote: > >> Or y

[go-nuts] Re: How to print arrays with commas and brackets

2020-08-07 Thread Henry
Or you can do it manually: func print(array []string) string { var buffer strings.Builder buffer.WriteString("[") for index, item := range array { if index != 0 { buffer.WriteString(", ") } buffer.WriteString("\"" + item + "\"") } buffer.WriteString("]") return buffer.String() } On Wednesday,

[go-nuts] Re: How to print arrays with commas and brackets

2020-08-07 Thread Henry
Or you can do it manually: func print(array []string) string { var buffer strings.Builder buffer.WriteString("[") for index, item := range array { if index != 0 { buffer.WriteString(", ") } buffer.WriteString("\"" + item + "\"") } buffer.WriteString("]") return buffer.String() } On Wednesday,

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

2020-08-05 Thread Henry
It is that darn time machine I am telling you. They have had it for years but they just keep it hidden from the rest of us. On Wednesday, August 5, 2020 at 4:17:42 PM UTC+7, Amarjeet Anand wrote: > > How come the first git commit for Go was in 1972? > > Anybody want to share the story behind the

[go-nuts] Re: Why we don't have simple throws error statement

2020-08-04 Thread Henry
I disagree with error handling proposals that hide the program flow's branching statements. In 1976, Thomas McCabe found a correlation between branching statements and bugs. His cyclomatic complexity uses program flow to measure code complexity. It is important that branching statements be

Re: [go-nuts] Getting experience with type parameter parens

2020-07-05 Thread Henry
I looked at the updated design draft for generics. As much as I crave the extra static type verification and generics in general, it makes me wonder now whether they are worth the extra complexity.

Re: [go-nuts] Re: Need help with go modules

2020-05-26 Thread Henry
You are right. Thanks for the correction. Import path is the correct Go term. On Monday, May 25, 2020 at 12:04:16 PM UTC+7, Jan Mercl wrote: > > On Sun, May 24, 2020 at 6:58 AM Henry > > wrote: > > To create a Go Module, step inside your project folder, and type go

[go-nuts] Re: Need help with go modules

2020-05-23 Thread Henry
b.com/henry/myproject", then inside your myproject folder, type *go mod init github.com/henry/myproject* To add a dependency, just code away as you normally would. Every time you build, go build tools will examine your import lines and automatically add those dependencies into your go.mo

[go-nuts] Re: Go Module and Build Tag

2020-01-30 Thread Henry
Got it. Thanks. On Wednesday, January 29, 2020 at 3:13:46 PM UTC+7, Volker Dobler wrote: > > Build tags are per build, not per package. > So no, you cannot. > > V. > > On Wednesday, 29 January 2020 04:03:15 UTC+1, Henry wrote: >> >> Hi, >> >&g

[go-nuts] Go Module and Build Tag

2020-01-28 Thread Henry
? Thanks Henry -- 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 vi

Re: [go-nuts] How do I initialize extemplate (a template engine in golang) so that I can use with Echo minimalist framework

2020-01-10 Thread Ehioje Henry Erabor
NewTemplate(path string) *Template { t := new(Template) t.templates = extemplate.New() } On Wed, Jan 8, 2020 at 5:23 PM Chris Burkert wrote: > xt := {} leaves the templates field nil. > > Ehioje Henry Erabor schrieb am Mi. 8. Jan. 2020 um > 15:59: > >> I a

[go-nuts] How do I initialize extemplate (a template engine in golang) so that I can use with Echo minimalist framework

2020-01-08 Thread Ehioje Henry Erabor
; [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x776c85] > goroutine 1 [running]: > github.com/dannyvankooten/extemplate.(*Extemplate).ParseDir(0x0, 0x8cb153, > 0xa, 0xcebf20, 0x1, 0x1, 0x32, 0x963ae0) > /home/henry/work/pkg/mod/github.com/dannyvankooten/extemplate@v0.0.

[go-nuts] Re: Problem with migration to the new "module" technology from "go"

2019-11-19 Thread Henry
You need to tell go module where to find the library. It defaults to using central repositories (such as github). If you have the library in the local machine, you can add into your go.mod file something like this: ``` replace namespace/to/pkgname => local/path/to/pkgname ``` When you run 'go

Re: [go-nuts] go module & local package

2019-10-10 Thread Henry
ic package like platform from > otherModule: > > import "github.com/userName/otherModule/platform" > > Here's a gentle introduction > <https://ukiahsmith.com/blog/a-gentle-introduction-to-golang-modules/> to > Golang Modules > > On Wed, Oct 9, 2019, 1:03 PM

[go-nuts] go module & local package

2019-10-09 Thread Henry
to create your go mod project outside of existing gopath? Thanks. Henry -- 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...@google

Re: [go-nuts] Is this a bug?

2019-05-24 Thread Henry
The posted diagram isn't correct. Updated the diagram with the new one. [image: go1.png] On Saturday, May 25, 2019 at 10:38:42 AM UTC+7, Henry wrote: > > Thanks for the reply. > > Is there any specific use case that this intended behavior is supposed to > solve? I

[go-nuts] Is this a bug?

2019-05-24 Thread Henry
Go apparently treat FormatterA and FormatterB as being different. //Is this a bug? func Print(f FormatterB, s StringerB) { fmt.Println(f.Format(s)) } Thanks Henry -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from t

[go-nuts] Re: Passing types that satisfy interfaces - a simple idea ?

2019-05-13 Thread Henry
You mean something like this <https://play.golang.org/p/wuyvgVYnwn_T>? Henry On Tuesday, May 14, 2019 at 12:40:01 AM UTC+7, x...@gmail.com wrote: > > (I suspect this is just another "generics" proposal masquerading as > something else - but I could find a discus

[go-nuts] Re: Go if else syntax .. suggested replacement

2019-04-25 Thread Henry
I disagree with the suggestion. IF statement indicates a branching of execution path. It should be made to stand out so that when people are skimming through the code can immediately pick up these alternate execution paths. Changing it to a mere "?" will reduce its visibility. You have to

[go-nuts] Re: built-in alternative to bcrypt?

2019-04-24 Thread Henry
Hello, If you want to store passwords, then bcrypt , scrypt , and argon2 are commonly used. They are available in Go's extended library. SHA is a

[go-nuts] Re: Persistence of value, or Safely close what you expected

2019-03-19 Thread Henry
Note that you don't need to clean up a channel. The GC will automatically free the channel when there is no more reference to it. The only reason to close a channel is to send a signal to the other goroutines that you are done and there is no more data to send. Other than that, you don't need

[go-nuts] Re: Go vs C speed - What am I doing wrong?

2019-02-11 Thread Henry
Micro optimization is only a small part of the picture. While you can shave off a few ms with micro optimization, you can save much more with macro optimization. Macro optimization deals with algorithm, program design, caching, etc. This is why some people consider language vs language

[go-nuts] Re: Alternative of defer?

2019-02-09 Thread Henry
How about this? //locking/unlocking mechanism is handled inside performOperation1 if err:= performOperation1(lock1); err!=nil { return err } performExpensiveOperation2() On Saturday, February 9, 2019 at 1:28:12 AM UTC+7, vincent163 wrote: > > I am thinking about how to write programs like

[go-nuts] go modules and vendor: redundant features?

2018-11-16 Thread Henry
and consolidating features. Go2 needs to be simpler than Go1.11 Henry -- 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 mo

[go-nuts] Re: Windows Build Problem

2018-11-06 Thread Henry
I manage to find the culprit. Apparently, Haskell bundles their own GCC and stuffs, and adds them to the path. As soon as Haskell is removed, it builds just fine. Thanks again. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

[go-nuts] Re: Windows Build Problem

2018-11-06 Thread Henry
Thanks for the reply. Are you able to build with CGO enabled? I can build without CGO support, but once I remove the cgo flag, the build will fail. I probably mess up my paths somewhere. On Tuesday, November 6, 2018 at 9:09:27 PM UTC+7, peterGo wrote: > > Henry, > > MinGW and TDM-G

[go-nuts] Windows Build Problem

2018-11-05 Thread Henry
Hi, I am having problems trying to build Go from source on my Windows 10 64-bit machine. If someone has done this, it would be great if you could show me how you set up your box (eg. which GCC version you are using, whether you are using MinGW vs TDM-GCC, etc.). Thanks. Henry -- You

[go-nuts] Go2 Error Handling Feedback

2018-11-01 Thread Henry
Hi, I am concerned with the direction Go2 is going. If anything, Go2 should reduce and consolidate features from Go1 rather than adding new ones. Remember that C++ and Java too were once simple languages and people keep adding stuffs instead of consolidating features. About error handling, I

[go-nuts] Re: Correct way to solve slice of interface type problem

2018-10-31 Thread Henry
Hi, You would need to manually convert []implementation to []data. See https://play.golang.org/p/DdC8sEGi75- On Wednesday, October 31, 2018 at 5:21:29 AM UTC+7, Yuri Shafet wrote: > > Hello, everyone. > Consider following code: > > package main > import "fmt" > > type implementation struct { >

Re: [go-nuts] Re: Go 2 Proposal Comments

2018-10-28 Thread Henry
the Linux kernel is still C89 AFAIK… (commit > <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=51b97e354ba9fce1890cf38ecc754aa49677fc89> > ) > > Btw, the additional keywords added after Java 1.0 through Java 11, 20+ > years later: > > enum strictfp _ (underscore) > &

[go-nuts] Re: Go 2 Proposal Comments

2018-10-26 Thread Henry
First, backward compatibility isn't free. The reason why you can still compile your "version 1.0" source is because someone gives some thoughts about it and puts some extra efforts to make it happen. Backward compatibility requires maintenance and adds constraints to future development. The

Re: [go-nuts] Go language should become an ANSI and ISO standard.

2018-10-12 Thread Henry
In my opinion, currently there is no need for Go 'standardization'. There aren't multiple implementation of Go where each vendor is eager to add their own features and promote their own version of Go. In fact, by giving up control to a committee (especially during this early stage of the

[go-nuts] Re: Error Handling Best Practice (error wrapping)

2018-10-09 Thread Henry
Hi, There are two kinds of errors: user-facing error and developer-facing error. User-facing error is an error that is supposed to be relayed back to the end-users. It is usually stripped from sensitive information and is generally more verbose. On the other hand, developer-facing error are

[go-nuts] Re: Proposal: Implicit Method Signatures

2018-09-28 Thread Henry
There was a similar proposal before. Some people insist that there should be a clear separation between state and behavior. Struct is for state and interface is for behavior. I too was toying with a similar idea before. My reasoning has less to do with trying to fit into an interface, but it

[go-nuts] Go 2 Draft Design Question : Error Handling

2018-09-08 Thread Henry
common processing for all the possible paths of execution. How does the new syntax cater with this need? Thanks. Henry -- 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 i

[go-nuts] Re: My trouble about GO interface

2018-08-10 Thread Henry
When designing a Go program, remember that there is no type hierarchy in Go. You create the actual Elephant, Tiger, etc., but not Animal since Animal is just a classification. In my fictional world, I may have Alice, Bob, and Charlie. If I need a banker, I just put up an ads with the job

[go-nuts] My trouble about GO interface

2018-08-09 Thread Henry
As far as I know, there are three ways you can deal with this. First, you can introduce a dummy private method in your interface, so as to differentiate it from other interfaces. The implementing struct will need to implement this dummy method. I don't like this approach for one bit, because it

[go-nuts] Re: formatting question/issue

2018-04-10 Thread Henry
I believe the first example (the one without the last comma) is when you want to put everything on the same line. The second example (the one with the last comma) is when you want to split the items into separate lines. They each have different uses. It is awkward to see this `{ 'A', 'B', 'C',

[go-nuts] Re: Language is a platform, which golang still does not pay attention to !!!

2018-04-06 Thread Henry
I think the OP was unaware of several facts: 1. Go has been moving up and down the top 10 most popular programming languages in various surveys. 2. Java and PHP are implemented using C/C++. The same goes with the networking components of the various operating systems. So to say that

[go-nuts] Re: Why should i use interface composistion

2018-03-13 Thread Henry
I would recommend doing the simplest things to make it work, and resort to more complex stuffs when you actually have the need for them. In the beginning, there were no *best practices* and people just took the easiest way to get their jobs done. Over the years, programming practices evolve.

Re: [go-nuts] Re: Why is there no standard `uuid` package?

2018-02-08 Thread Henry
@axel: The specification for UUID is defined in RFC 4122. You are free to use it or create your own variants. However, the specs is there. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

[go-nuts] Re: Why is there no standard `uuid` package?

2018-02-08 Thread Henry
I don't think UUID representation (whether with dash or without dash or how many dashes) is a strong argument for not including UUID into Go's stdlib. You can expose it in byte array, provide the default implementation for its string representation, and let the users work with the byte array if

Re: [go-nuts] Re: Go : Philosophy

2017-09-20 Thread Henry
I think pretty much of Python philosophy is transferrable to Go as the two languages seem to share a similar outlook. -- 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

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

2017-09-10 Thread Henry
Actually, there is nothing in Go that prevents you from using any kind of frameworks. You are free to use whatever you wish. Go provides a more complete standard library for web development than many other programming languages. While in other languages you have to rely on frameworks, in Go,

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-21 Thread Henry
like JSONNumber. It is more descriptive than "int?" and easier to maintain in the long run. On Monday, August 21, 2017 at 8:24:26 PM UTC+7, Tong Sun wrote: > > > On Monday, August 21, 2017 at 3:44:41 AM UTC-4, Henry wrote: > > In my opinion, if you need a nullable type,

Re: [go-nuts] Go 2 suggestion - Types like "int?"

2017-08-21 Thread Henry
In my opinion, if you need a nullable type, you're entering a domain problem. You are better off creating your own ADT (abstract data type) with more descriptive names rather than "int?" or "float?". -- You received this message because you are subscribed to the Google Groups "golang-nuts"

[go-nuts] Re: Calling Once (in the code)

2017-08-11 Thread Henry
p.LastName = data.LastName > p.MiddleName = data.MiddleName > p.MobileNumber = data.MobileNumber > p.PhoneNumber = data.PhoneNumber > } > > Now the sole purpose of functions validateData and transferData is > providing a clean and more descriptive code. They should appea

  1   2   >