[go-nuts] Re: Rendering fonts in Go

2023-12-22 Thread Howard C. Shaw III
I think Freetype may still be your best bet - but rather than the Freetype 
port, you would need to use a wrapper that calls the Freetype C library, 
such as https://github.com/danielgatis/go-freetype

-- 
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/7b2358fd-dcdc-49a9-954e-8b9d4094d843n%40googlegroups.com.


Re: [go-nuts] go1.21.0 panics when loading plugin

2023-09-05 Thread Howard C. Shaw III
It looks to me like the regexp package has an func init() that never gets 
called when Re is only imported in a plugin, which is why it works when you 
uncomment the lines that use regexp in the main package.

Howard

-- 
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/272c1bc4-ec9e-4ac4-b023-9ed8fee865c3n%40googlegroups.com.


[go-nuts] Re: Download large Zip file via sftp

2023-09-05 Thread Howard C. Shaw III
I want to second what Ozan has said, use *sftp.Client not sftp.Client, but 
I want to throw out a couple of words about that.

First, the documentation specifically warns against copying Mutex. So you 
need to be fairly certain that no mutexes are used in a  struct before 
using value semantics. Anything that mentions it is using concurrency or is 
safe to use under concurrency is likely to be using mutexes, so probably 
needs pointer semantics. 

Second, I want to recommend that in looking at the documentation, you pay 
particular attention to the method signatures, and especially the receiver. 
If in the documentation of a struct all the methods have a pointer 
receiver; i.e. they look like:

func (c *Client) Close() error
 ^^^
having the * in front of the class name, this is a good indication that you 
need to pass it around yourself in that way. If they all look like:

func (c Client) Close() error

without the *, then you are pretty safe to pass it around as a value, since 
all the method calls are going to be doing that anyway.

Finally, if the documentation includes a New{Struct} function, pay 
attention to the return type - if it returns a pointer, pass it around as a 
pointer. If it returns a value, then you can probably leave it as a value.

Good luck!

Howard

-- 
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/d90b8913-49c3-4f9d-8277-25dff1b0eed5n%40googlegroups.com.


[go-nuts] Re: `go get` and workspaces (`go.work`)

2023-07-14 Thread Howard C. Shaw III
Such an issue is what I linked you to earlier in the thread. So I do not 
think you need to create a new issue - however, in the comments in that 
issue one of the devs asks for use cases where go work sync is not 
sufficient, so you might want to reply to that with your example where go 
work sync has not been sufficient.

https://github.com/golang/go/issues/50750

Well, it is actually about go mod tidy, but the discussion mentions go get 
as well, and is generally about why the other tools ignore go.work and 
whether this should be changed. So I think it is the appropriate forum for 
that discussion.

-- 
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/27741a17-1056-4bfd-8ed6-19009aa31028n%40googlegroups.com.


[go-nuts] Re: `go get` and workspaces (`go.work`)

2023-07-11 Thread Howard C. Shaw III
Okay, yeah, got home and tried it out, and go work sync is not doing what I 
thought it was. I had to do 

go get github.com/janpfeifer/gonb/gonbui

in a to get it to build and run.

So yeah, if you want to use a bare go get, you have to do replace 
directives. Blech.

-- 
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/035163e8-3ec8-4b24-b316-3a97f69ac608n%40googlegroups.com.


[go-nuts] Re: `go get` and workspaces (`go.work`)

2023-07-11 Thread Howard C. Shaw III
I'm not suggesting that it would fix go get, but that it replaces it. Add 
your extra third party reference, then do go work sync and it should 
download that dependency.

-- 
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/39adef7e-2b3b-4e96-884d-58f62bc533fan%40googlegroups.com.


[go-nuts] Re: `go get` and workspaces (`go.work`)

2023-07-11 Thread Howard C. Shaw III
Also did you call go work sync? I think that might be what I actually use 
in place of go mod tidy. Sorry, ToTK has been absorbing my free time, so it 
has been a while since I worked on the audio project where I used 
workspaces.

https://github.com/golang/go/issues/50750

"*bcmills  *commented on Jul 25, 2022 


go mod tidy is intended to update the module's self-contained dependencies. 
It doesn't use the workspace because in general one may work on multiple 
independently-maintained modules in the same workspace, and if you're 
preparing an upstream commit you definitely don't want that commit to rely 
on unpublished local modifications.

go work sync is intended to update the modules within a workspace to 
reflect the dependencies selected in that workspace. That is probably what 
you want if you are working on a set of modules that are all maintained as 
a single unit."
It seems like currently you are basically forced to use 'go work sync' to 
update dependencies when using workspaces, and not use 'go mod tidy' or a 
bare 'go get'.

-- 
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/0acd6b8a-f747-425c-82e6-f2718447bb41n%40googlegroups.com.


[go-nuts] Re: `go get` and workspaces (`go.work`)

2023-07-11 Thread Howard C. Shaw III
What directory did you do the go work init in? The setup description reads 
like you did it in work/a - shouldn't it be in /work? Can you check where 
your go.work file is? 

-- 
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/eab4e299-a678-4d9d-90c6-bbd5dccefd82n%40googlegroups.com.


[go-nuts] Re: `go get` and workspaces (`go.work`)

2023-07-11 Thread Howard C. Shaw III
I don't think you need to run go get there at all - just run go mod tidy, 
and then when you go build, if it needs something it will get it. If you 
need to download without building, go mod download will do that.

Howard

-- 
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/08d2686d-6c72-4b7d-9579-b7c299baca3an%40googlegroups.com.


[go-nuts] Re: Modules... why it has to be so painfull?

2023-05-19 Thread Howard C. Shaw III
Workspaces make this all much easier for me.
https://go.dev/doc/tutorial/workspaces

go work

I was going mad trying to get modules to work reasonably until I found 
that. Now, new directory, go mod init , go work use ., go work sync, 
go tidy, and everything works reasonably without major headaches.

Howard

-- 
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/6523cd7d-7fa2-4860-b2d6-889c7105882fn%40googlegroups.com.


[go-nuts] Re: Why can't a regexp.Regexp be const

2023-02-14 Thread Howard C. Shaw III
var ExtRegex = 
regexp.MustCompile("(M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$")

with a 
./prog.go:10:18: 
regexp.MustCompile("((M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$") (value of 
type *regexp.Regexp) is not constant


Actual error I get is "error parsing regexp: unexpected ): 
`(M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$`"
It is missing a parentheses. This compiles fine:
 
var ExtRegex = 
regexp.MustCompile("((M|m)(p|P)(3|4))|((F|f)(L|l)(A|a)(C|c))$")
Note that there are two parentheses after the double-quote.

-- 
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/a5acd2a9-d0a7-4bd0-8712-13f5f0f6n%40googlegroups.com.


[go-nuts] Re: Endless Running Goroutine Terminates Without Panic

2023-01-27 Thread Howard C. Shaw III
Ctrl-\ in a Linux terminal sends the SIGQUIT signal. You can also send this 
signal with kill.

Sending SIGQUIT to a golang application (unless it traps it and changes the 
behavior) will cause it to print all of its goroutine's stack traces and 
then exit.

Perhaps you could use this to confirm that the goroutines have in fact 
exited and are not actually stuck waiting on a lock or IO?

Then if they *have* exited and have not tripped your recover, it was due to 
running to the end of the function and not a panic - so add a logging step 
at the end of the function to confirm this, and then investigate how it can 
reach that point without a panic. And if they have *not* exited, then the 
stacktrace should reveal what they are getting hung up on.

-- 
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/a244c851-3287-4062-b04d-354cd1828727n%40googlegroups.com.


[go-nuts] Re: How to get name of variable name from pointer name?

2022-08-30 Thread Howard C. Shaw III
In the instant example where you have the name in the code, just include 
the name as a string:

fmt.Printf("Type: %T, Name:%#+v\n", myVariable, "myVariable")

But in the general case where that pointer value has been passed to a 
function or stored in a map or slice and you are referencing it only from 
the map or slice, I do not think you can, at all, because the pointer is 
NOT pointing at the variable. Rather, the variable and the pointer are 
referencing the same in-memory object, and that object has no name. 

Consider this tweak to your example: https://go.dev/play/p/aX7MfsnuZPZ
What name would either of these return? All of these variables in the end 
point to the same place - if before all the myVariableX= lines there was a 
Val := "Swiss Cheese"
myVariable = &Val
, every one of those variables would point to the string "Swiss Cheese", 
and would have the same pointer value. What then, should the name of that 
pointer be?

>From the computer's perspective, it is not a sensical question.

-- 
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/adea855d-b9dc-4e51-a45e-11d413f5a791n%40googlegroups.com.


[go-nuts] Re: Microsoft Adaptive card

2022-07-22 Thread Howard C. Shaw III
I'm not really sure how Go relevant this is - but the Adaptive project on 
GitHub says the license is MIT, so even if the project folds, you could 
just fork it. https://github.com/microsoft/AdaptiveCards/blob/main/LICENSE
Given that the rendering is a client-side thing, couldn't you use the 
Javascript renderer that already exists for them?
https://github.com/microsoft/AdaptiveCards/tree/main/source/nodejs/adaptivecards
I know it says nodejs in the path, but as far as I can see, this piece, the 
renderer, is actually client-side. 

https://unpkg.com/adaptivecards/dist/adaptivecards.min.js

-- 
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/35d30625-1d75-487e-9c1f-658f2ae4a10cn%40googlegroups.com.


[go-nuts] Re: find hwnd on win 10

2022-06-26 Thread Howard C. Shaw III

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setforegroundwindow

"The system restricts which processes can set the foreground window. A 
process can set the foreground window only if one of the following 
conditions is true:

   - The process is the foreground process.
   - The process was started by the foreground process.
   - The process received the last input event.
   - There is no foreground process.
   - The process is being debugged.
   - The foreground process is not a Modern Application or the Start Screen.
   - The foreground is not locked (see LockSetForegroundWindow 
   

   ).
   - The foreground lock time-out has expired (see 
   *SPI_GETFOREGROUNDLOCKTIMEOUT* in SystemParametersInfo 
   

   ).
   - No menus are active.

An application cannot force a window to the foreground while the user is 
working with another window. Instead, Windows flashes the taskbar button of 
the window to notify the user."

https://stackoverflow.com/questions/19136365/win32-setforegroundwindow-not-working-all-the-time

This is more of a Windows API question than a Golang question, so you might 
do better to direct your questions to a Windows forum. The second link 
above does describe a workaround involving AttachThreadInput. I'm not sure 
if w32 has that function mapped or not - if not, you can 
try https://pkg.go.dev/github.com/xpzed/win32

Good luck!

-- 
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/d7ebe7a4-c5c1-4164-a19e-4b4a614d3eaan%40googlegroups.com.


[go-nuts] Re: Concurrent solution: Which is the most efficient way to read STDIN lines 100s of MB long?

2022-06-21 Thread Howard C. Shaw III
There seems to be a conflict between these two statements:
>  should output every line that contains a search word "test" to STDOUT. 
and
>  If one goroutine finds it I can stop the other 7 from working. 

If it is supposed to output EVERY line containing test, what is the logic 
that says you can stop the other goroutines? Is this because you have done 
something ahead of time that separates the input into lines, and so you 
know all the goroutines are operating on the same line? 

It looks, frankly, more like this is code to 'repeat STDIN on STDOUT if 
test is present anywhere in STDIN,' with no cognizance of lines at all.

As long as that is what you are intending to do, rather than the described 
task, then you don't need to worry about stopping the other goroutines at 
all!

"Program execution begins by initializing the main package and then 
invoking the function main. When that function invocation returns, the 
program exits. It does not wait for other (non-main) goroutines to 
complete." -- https://go.dev/ref/spec#Program_execution

Simply exiting from your main when you have completed your read from STDIN 
and your write to STDOUT upon any of the goroutines returning a 
confirmation will end the program, whether other goroutines are still alive 
or not.

Howard


-- 
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/6982a8fd-88a5-4400-87b5-8b0c182000cen%40googlegroups.com.


[go-nuts] Re: find hwnd on win 10

2022-06-21 Thread Howard C. Shaw III
On what basis are you using globs ("*lient*", etc) in FindWindow? If I 
understand correctly, the w32 and w32a packages are just wrapping Windows 
APIs, so the semantics of the use should match the equivalent use of the 
windows API. The documentation for FindWindow says "Retrieves a handle to 
the top-level window whose class name and window name match the specified 
strings." - that does not appear to me to be implying that it supports 
globbing.

See this relevant question on 
StackOverflow: 
https://stackoverflow.com/questions/16530871/findwindow-does-not-find-the-a-window

You might find the EnumWindows function more useful, as you can loop over 
the returned windows, and use GetClassName and GetWindowText to get some 
text you can then compare against.

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumwindows
 

-- 
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/cac11ef5-4890-41e7-9e6b-08960c32728cn%40googlegroups.com.


[go-nuts] Re: Drawing millions of images on a bigger canvas

2022-01-24 Thread Howard C. Shaw III
One more options to add to  Tamás' suggestions - due to Go's interface 
design, implementing a draw.Image, which is an image.Image with an 
additional Set(x, y int, c color.Color) method, is sufficient to use 
draw.Draw for compositing.

As such, you can pre-allocate a flat-file with sufficient space to store 4 
x 8 x width x height bytes 
(4 for RGBA, 8 for float64 in bytes), and have your implementation of 
draw.Image reading and writing 
to the file by offset. This would minimize memory usage in exchange for a 
massive slowdown, as 
every *pixel* operation would now be a read or write to a file, but only 
one of the small files needs to be open
at a time. MMapping this file can get some of the performance back, as Tamás 
suggested, or you can have the file be on a RAMdisk - this alleviates less 
of the performance issue, as it still requires filesystem operations 
per-pixel, but is not as slow as dealing with actual spinning media. 

You would still at some point need to pull in the entire large file to 
write it into a usable format, so whether there is any significant 
advantage depends on whether your large file has an area equal to or larger 
than the sum of the areas of the individual images - that is, to what 
degree the images are being composited with overlap.


 

-- 
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/2710cbd7-ed44-4343-830b-1b661d0b70d7n%40googlegroups.com.


[go-nuts] Re: profiling help

2022-01-12 Thread Howard C. Shaw III
The 17% is sleeping. The 70% is garbage collection.

On Wednesday, January 12, 2022 at 3:54:32 PM UTC-6 st...@rothskeller.net 
wrote:

> I am attempting to profile my code, and I'm unable to interpret the 
> results.  So first, the meta-question is, what's the best forum to use to 
> request help with such things?
>
> The code I'm profiling is the server side of a moderately complex webapp.  
> For simplicity, I've wrapped it with net/http/cgi and am calling it from 
> the command line as a CGI "script".  As such, it is handling a single 
> request with no actual network traffic.  Also, I've disabled the garbage 
> collector.  I'm calling pprof.StartCPUProfile at the top of ServeHTTP.  The 
> pprof output is at
>
> https://scholacantorum.org/pprof.svg
>
> It shows three different call chains.  The one that actually includes my 
> code, starting at runtime.main, is only 6% of the total CPU samples.  There 
> are two other call chains that are entirely within the runtime package, one 
> of them taking 17% of the time and the other taking a whopping 70% of the 
> time, and I can't figure out what they're doing.  I would appreciate any 
> guidance.
>
> The chain that is taking 70% of the time is
>
> gcBgMarkWorker
>
> systemstack
>
> gcBgMarkWorker.func2
>
> gcDrain
>
> markroot
>
> markroot.func1
>
> suspendG
>
> Underneath suspendG it splits into nanotime, osyield, procyield, and 
> preemptM, the latter of which has signalM, tgkill, and getpid children.  
> getpid alone is shown as taking 4% of the CPU of the entire program!  What 
> the heck is this call chain doing, with nearly three quarters of my time?
>
> The chain that is taking 17% of the time is
>
> mcall
>
> park_m
>
> schedule
>
> findrunnable
>
> stopm
>
> mPark
>
> notesleep
>
> futexsleep
>
> futex
>
> Again I have no clue what this is doing.  Any guidance is welcome, 
> including pointers to other forums better suited for such questions.
>
> Regards,
> Steve
>
>

-- 
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/1e1ce42b-fea3-4247-9d20-558caed4093bn%40googlegroups.com.


[go-nuts] Re: generics: what can we do with an any type?

2021-12-16 Thread Howard C. Shaw III
The code you wrote is using a generic value, but it is not itself generic. 
There is only one instantiated version of the runInt() function, and it 
knows (at compile-time!) that mySet is an map[int]int.

Make that function actually generic - something like:
func testThing[K comparable, V any](m map[K]V) {
if m[1337] == 1337 {
print("OK")
} else {
print("nope")
}
}
and you get
./prog.go:xx:yy: cannot use 1337 (untyped int constant) as K value in map 
index 
./prog.go:xx:yy: cannot convert 1337 (untyped int constant) to V

-- 
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/e1f79d1d-3759-4fcc-a5a8-2d1e88599074n%40googlegroups.com.


Re: [go-nuts] What is the total max size of embed content?

2021-09-22 Thread Howard C. Shaw III
Before the addition of binary packaged assets into Go as a standard library 
feature, there were various tools to accomplish the same task. Some of 
them, such as https://github.com/GeertJohan/go.rice , could use an 
alternate embedding. Basically, instead of having the binary files packaged 
as Go code in the executable itself, they simply appended a .zip file to 
the binary, and accessed that directly. 

Now, I am not suggesting that as a direct solution (though it may be, as Go 
does apparently support Zip64 which does away with the 4GB limit), but 
perhaps instead looking at how it does what it does, and adapting that to 
simply appending a sqlite or other single-file database format to the Go 
binary and using the same basic technique for accessing it.

-- 
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/bf1b9b41-50b2-4221-8389-7d184e9bc8a5n%40googlegroups.com.


[go-nuts] Re: I just published : Iterator lib for Go: Library providing Map(), Filter(), Reduce() for Go

2021-09-03 Thread Howard C. Shaw III
Just so you are aware of what's out there:

https://github.com/robpike/filter

"I wanted to see how hard it was to implement this sort of thing in Go, 
with as nice an API as I could manage. It wasn't hard.

Having written it a couple of years ago, I haven't had occasion to use it 
once. Instead, I just use "for" loops.

You shouldn't use it either.

Rob Pike

"

https://github.com/JohnCGriffin/yogofn - uses reflection, but has 
non-reflective code for float64, int, and string slices.

https://github.com/kulshekhar/fungen - uses go generate to create list-like 
types with MRF functions.

https://github.com/thoas/go-funk - reflect-based generic MRF, along with 
some single-typed instances

https://github.com/benashford/go-func - another reflection based MRF

https://blog.gopheracademy.com/advent-2015/glow-map-reduce-for-golang/ - 
glow is more like your example, using channels for MRF, but adds the 
ability to shard and distribute the shards.

You might want to look over these and see what differentiates your solution 
so that you can mention it in your Readme.MD. Also, don't forget that 
generics are coming in 1.18, and they are already enabled in go-tip, so you 
can be working on a non-reflection based generic solution.

-- 
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/977e8819-c19d-4798-b8d7-277feea0dc7cn%40googlegroups.com.


Re: [go-nuts] Re: fonts, bitmap and the (old TeX) PK file format

2021-09-01 Thread Howard C. Shaw III
Cool.

As to the Postscript interpreter,  look at
https://github.com/llgcode/ps

Also, font specific
https://github.com/golang/image/blob/master/font/sfnt/postscript.go

Not sure how much either helps towards Type 1 support.  Even Adobe is end
of lifing Type 1 support,  though,  so it might be worth seeing if you can
find a table of maps to help you find the closest OpenType match instead.

Best of luck!

-- 
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/CAPRFAb_s-DFYezn2m-2NDgq93dvQMCejFBRyeBNhXpm%2BQCtPXg%40mail.gmail.com.


[go-nuts] Re: fonts, bitmap and the (old TeX) PK file format

2021-09-01 Thread Howard C. Shaw III
You would implement the Face interface to have your fonts available to Go's 
text drawing routines.  You can try using basicfont directly, however it is 
fixedwidth only. But just implementing the interface does not seem that 
onerous.

Have a look at https://github.com/hajimehoshi/bitmapfont for an example of 
implementing Face for a mostly fixed-size bitmap font (by the author of the 
Ebiten game engine).   hajimehoshi's file gives an example of dealing with 
a *mostly* fixed width file, where certain characters (i.e. East Asian 
glyphs) can be double-width. 

Also https://github.com/textmodes/font 

Not https://github.com/usedbytes/fonts - this one does not implement the 
Face interface.

However, while that would gain interoperability of your PK fonts with Go's 
text flow engine isn't TeX emulation pretty much going to require you 
roll your own text flow engine anyway? I mean, that is kind of the heart of 
TeX, using font metrics to flow text. And so in that case, looking at  
https://github.com/usedbytes/fonts, which ignores the Face and golang Font 
and rolls its own text flow for rendering bitmap fonts onto Images might 
actually be a useful example but only so far, because I believe it also 
assumes a fixed width font.

And no form of fixed width font handling is going to suffice to mimic TeX; 
but again, really, with TeX what you need to be parsing from the .pk file 
is the font metrics, really. TeX never cared about the glyphs. That is why 
TeX's output was a DVI (DeVice Independent) file that had to be combined 
with font files to render an actual printable or viewable output. Except 
that I don't know that the PK file even has the font metrics - I think back 
then they were in a separate .tfm file?

This is relevant because one of the important elements that TeX handled was 
the concept that glyphs, properly kerned, can *overlap*. That you cannot 
use the width of the glyph to know how far to move forward to draw the next 
one - that was a separate metric. (Not saying it was the first, just that 
it is one of the important features.)

Again, not to take anything away from having success parsing the .pk file 
format - kudos to you. I'm just not sure not only whether it will actually 
be helpful in emulating TeX, but whether it is even needed. Theoretically, 
you should be able to fully emulate TeX in processing a TeX-format file 
into a DVI without ever touching any font glyphs at all, just the metrics. 

-- 
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/72a52d29-756f-4b6c-abce-fcb9c39eed46n%40googlegroups.com.


[go-nuts] Re: It's possible to replace cgo memory allocator?

2021-06-10 Thread Howard C. Shaw III
The DGraph.io team has a blog post about swapping to using jemalloc for CGo 
(they are going further and feeding their allocations into Go to avoid 
garbage collection, but that is a separate issue). 

https://dgraph.io/blog/post/manual-memory-management-golang-jemalloc/

On Thursday, June 10, 2021 at 2:19:15 PM UTC-5 di3go.b...@gmail.com wrote:

> I'm using cgo and struggling to find a memory leak which can be easily 
> detected if I can replace the cgo memory allocator to the one the C library 
> I'm using have because they did a leak detector implementation there.
>
> It's possible?
>
>
>

-- 
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/2f582d3f-81bf-4863-8d36-dd09624d74b6n%40googlegroups.com.


[go-nuts] Re: What are the analogues of PostCSS for go

2021-05-27 Thread Howard C. Shaw III
Take this with a grain of salt, as I've never used PostCSS and had to look 
up what it even was.

https://github.com/ysugimoto/gssp - this is Golang Style Sheet 
Postprocessor which appears to be at least directed at the same task.

Of course, as PostCSS is a tool that applies to .css files, there is no 
particular reason you need to reimplement it in Go to be able to use it 
with Go based serving; the Hugo Go framework apparently includes PostCSS 
integration of some 
sort: https://andrewdavis.me/post/rewriting-my-personal-site-with-hugo/ has 
an example under the heading Integrated CSS Processing.

Given that, as I understand it, part of the appeal of PostCSS is the 
library of modules for it, and the fact that these modules are certainly 
not going to be compatible with a Go reimplementation, you may need to 
consider whether you use any modules and what would be involved in 
reimplementing their functionality before moving to a pure-Go solution.

-- 
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/13a7972e-13de-41c0-8984-38518d55b83cn%40googlegroups.com.


[go-nuts] Re: Map to struct and vice versa

2021-05-17 Thread Howard C. Shaw III
The examples given in other responses are great if you need to handle 
arbitrary or unknown maps and very much fit the 'easy way' part of your 
initial question. But you also asked at the end 'is there a more direct 
way?'.

If you actually know what you are getting, you can code it entirely 
directly:

t := T{
A: m["a"].(string),
B: m["b"].(int),
}

and back again

m2 := map[string]interface{}{}
m2["a"] = t.A
m2["b"] = t.B

https://play.golang.org/p/4OY3QoA5Mr3

Why would you not do this? Because your assignment will panic if you pass 
an m that is missing "a" or "b". Not fun. (Something like "panic: interface 
conversion: interface {} is nil, not int") Of course, you can always 
collect the values from the map into temporaries before creating the type 
and handle any nils in that process. Or pass your map through a validation 
step that ensures it is safe to convert before passing it to the conversion.

-- 
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/4a705e62-68f0-4136-804b-826eea48bc9dn%40googlegroups.com.


Re: [go-nuts] time.Format with "Month Year" format incorrectly displayed

2021-05-06 Thread Howard C. Shaw III
Alternatives:
Excel style formatter: https://github.com/metakeule/fmtdate
bday, err := fmtdate.NewTimeDate("-MM-DD", "2000-12-04")

C-library style formatter: 
https://github.com/lestrrat-go/strftime
https://github.com/fastly/go-utils/strftime -- deprecated
https://github.com/jehiah/go-strftime
https://github.com/tebeka/strftime

str, err := strftime.Format("%Y-%m-%d %H:%M:%S", t)
str, err := strftime.Format("%Y/%m/%d", time.Now())

C-library style formatter with different interface, includes parsing using 
C-library format specifiers:
https://github.com/bmuller/arrow
// formatting 
fmt.Println("Current date: ", arrow.Now().CFormat("%Y-%m-%d %H:%M")) 
// parsing
parsed, _ := arrow.CParse("%Y-%m-%d", "2015-06-03") 

Parsing:
Useful for parsing date strings when you don't necessarily know the 
dateformat ahead of time, or the format can vary:
https://github.com/araddon/dateparse

Howard

-- 
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/fc4cb84f-5cde-46af-8834-2681e07f1828n%40googlegroups.com.


[go-nuts] Re: I'd like to write a CSS StyleSheet Parser but...

2021-01-04 Thread Howard C. Shaw III
An AST (Abstract Syntax Tree) is exactly what the common output of a parser 
is, and you can see an example of it in the Go source code. But not always 
- the output of a parser can also be function calls, as in a streaming XML 
(SAX) style parser. 

The important elements of a parser is that it knows or implements a 
grammar, and can report grammatical and syntactical errors, and in the 
absence of them, provides information to some subsequent activity that is 
known to be grammatically and syntactically correct. 

When the input can be described by a formal grammar such as EBNF, then yes, 
there exist tools that can take an EBNF grammar and write a parser for it, 
which returns an AST that can then be operated over. 

The project that stephan linked you to actually already contains a CSS3 
parser; however, to answer your other 
question: https://github.com/goccmack/gocc is a package that allows you to 
generate a lexer/parser pair from a BNF 
definition. https://github.com/goccmack/gogll works on a subset of valid 
grammars (context-free grammars) to produce lexers and parsers.

-- 
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/2fed3839-cb18-4635-be4f-b452fd7a97f2n%40googlegroups.com.


[go-nuts] Re: JSON dictionary encoding

2021-01-04 Thread Howard C. Shaw III
It is not JSON at that point - and if you want a JSON compatible format 
that compresses, well, there are dozens of them - some just elide the 
keynames, others include compression of the data elements as well. Here is 
an article discussing a lot of 
them: 
https://www.lucidchart.com/techblog/2019/12/06/json-compression-alternative-binary-formats-and-compression-methods/

Many of them have Go-language implementations.

On Monday, January 4, 2021 at 1:09:44 PM UTC-6 ChrisLu wrote:

> Hi,
>
> For a list of json objects, the key names are usually repeated.
> e.g., {:1, :2},{:2, :3}, ...
>
> The key names, "" and "" for the above example, could be very long.
> Is there any existing library already encode json objects via a dictionary?
>
> This is a JSON-specific compression. Would be good to see the compression 
> ratio compared to gzip, which has a general dictionary encoding.
>
> Chris
> --
> https://github.com/chrislusf/seaweedfs
>

-- 
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/37f93d1e-3f85-4672-9aba-c262af30a7ecn%40googlegroups.com.


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

2021-01-04 Thread Howard C. Shaw III
I posted two real world problems where Generics would be useful to me, 
earlier in the thread. Saw no response, and now continued claims that no 
real world problems have been provided? I'm not sure if that is 
disingenuous, or merely an artifact of the client someone is using causing 
replies that split the thread in some other people's clients so that not 
all the responses are visible, which resulted in an accusation of starting 
multiple threads that was hashed out a bit ago. 

The post was dated Dec 24, 2020, 12:50:53 PM. (CST)

-- 
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/2622f58c-9a78-43aa-9e7a-fea989faed87n%40googlegroups.com.


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

2020-12-24 Thread Howard C. Shaw III
I do not have an example implemented with generics, but I do have examples 
that could use them. My renderview - https://github.com/TheGrum/renderview 
; in particular this 
file: https://github.com/TheGrum/renderview/blob/master/renderparameter.go 
and my still unpublished audio library, visible in pre-release form in the 
processor.go file in https://github.com/TheGrum/rosarygen could both 
benefit from generics. Both have the pattern of having a struct that has 
multiple elements and a type flag, where only one of the elements will 
actually have a value at a time (though the struct that has that pattern in 
processor is not yet present in the rosarygen code). 

They certainly work, but they abandon compile-time type guarantees, 
dropping down to runtime type-casting. They are also brittle to extension. 
I can extend them, but it means adding cases to type-switches in certain 
bits of code. Someone using them as libraries could not do so very easily, 
or possibly at all.

-- 
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/e2b03a06-51eb-4d32-a03e-c5d7d5f7b8ecn%40googlegroups.com.


[go-nuts] Re: Command line tool to modify YAML files

2020-11-02 Thread Howard C. Shaw III
If written because you needed experience and writing a program to perform a 
task you need done is better for learning, then go you! But if you are 
legitimately looking to solve a problem, you might want to throw a quick 
search out first before implementing Yet Another X.

For yamlfukr update file.yaml key value:
https://github.com/mikefarah/yq
yq w -i file.yaml key value

yq also supports b.c.d.e key names to edit deeper values.

https://github.com/TomWright/dasel

dasel put string -f file.yaml -p yaml "key" value

dasel also supports b.c.d.e key names to edit deeper values.

https://github.com/grasmash/yaml-cli
yaml-cli update:value file.yml key value  

If you intend to keep developing yamlfukr 
, you might want to examine some 
of the alternatives, and if you find them unsuitable, add to your 
documentation why you find them so, so that someone coming on your project 
can see why they should consider going with your tool instead of one of the 
alternatives.

-- 
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/b1fb908a-94f7-4487-b76a-50153d87c868n%40googlegroups.com.


Re: [go-nuts] Question on the generics proposal and arrays

2020-10-07 Thread Howard C. Shaw III
You said: 

> I was trying around with arrays and generics because slices are more 
> complex to reason about than arrays. For example, I introduced bugs into my 
> code by not being fully aware of slices overwriting original data when you 
> append to them and the capacity is not set correctly. So, when writing 
> critical code it could be safer to avoid slices if possible for 
> this reason. Another example:
>

In my experience, you either have a fixed array size in mind to begin with 
(as in a fixed array size in a struct for padding or matching a fixed size 
C array) or you should be using a slice anyway. 

The trouble mostly comes when you keep the array around after making a 
slice of it. If you are  going to be doing *any* manipulation of a slice, 
abandoning the underlying array and only carrying around slices gets rid of 
most such errors. A slice already IS effectively an 'array, generic on 
size.'

-- 
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/08fe15f5-dff1-4651-b824-86266b3ce50bn%40googlegroups.com.