alpha

Gives a coding assistant idiomatic Go rules: naming, error handling, concurrency, testing, project layout and common mistakes to avoid.
description: 'Instructions for writing Go code following idiomatic Go practices and community standards'
applyTo: '/*.go,/go.mod,**/go.sum'
Follow idiomatic Go practices and community standards when writing Go code. These instructions are based on [Effective Go](https://go.dev/doc/effective_go), [Go Code Review Comments](https://go.dev/wiki/CodeReviewComments), and [Google's Go Style Guide](https://google.github.io/styleguide/go/).
if condition { return } pattern to avoid else blocksstrings.Builder for string concatenation, filepath.Join for path construction)util, common, or basepackage declarations - each Go file must have exactly ONE package line.go file:package declaration - do not add another one.go file:.go files in the same directory usepackage <name> line at the very top of the filepackage declaration before adding onepackage declaration in the new contentpackage lines or duplicate declarationshttp.HTTPServer, prefer http.Server)Reader, Writer, Formatter)Read → Reader)const blocksgofmt to format codegoimports to manage imports automatically//) for most comments/* */) sparingly, mainly for package documentation_ unless you have a good reason (document why)fmt.Errorf with %w verberrmain packages in cmd/ directorypkg/ or internal/internal/ for packages that shouldn't be imported by external projectsgo.mod and go.sum)go mod tidy to clean up unused dependenciesany instead of interface{} (Go 1.18+)sync.WaitGroup or channels to wait for goroutinesselect for non-blocking operationssync.Mutex for protecting shared statesync.RWMutex when you have many readerssync.Once for one-time initializationgo >= 1.25 in go.mod, use the new WaitGroup.Go method ([documentation](https://pkg.go.dev/sync#WaitGroup)):var wg sync.WaitGroup
wg.Go(task1)
wg.Go(task2)
wg.Wait()
go < 1.25, use the classic Add/Done patternerrors.New for simple static errorsfmt.Errorf for dynamic errorserrors.Is and errors.As for error checkinghttp.HandlerFunc for simple handlershttp.Handler for handlers that need statego >= 1.22, prefer the enhanced net/http ServeMux with pattern-based routing and method matchinggo < 1.22, use the classic ServeMux and handle methods/paths manually (or use a third-party router when justified)json.RawMessage for delayed parsing*http.Client, auth, default headers). It must not store any per-request state*http.Request inside the client struct, and do not persist request-specific state across calls; instead, construct a fresh request per method invocationcontext.Context and input parameters, assemble the *http.Request locally (or via a short-lived builder/helper created per call), then call c.httpClient.Do(req)http.Request (URL params, body, headers) as fields on the long-lived client*http.Client is configured (timeouts, transport) and is safe for concurrent use; avoid mutating Transport after first usedefer resp.Body.Close()), handling errors appropriatelysync.Pool)Most io.Reader streams are consumable once; reading advances state. Do not assume a reader can be re-read without special handling
If you must read data multiple times, buffer it once and recreate readers on demand:
io.ReadAll (or a limited read) to obtain []byte, then create fresh readers via bytes.NewReader(buf) or bytes.NewBuffer(buf) for each reusestrings.NewReader(s); you can Seek(0, io.SeekStart) on *bytes.Reader to rewindFor HTTP requests, do not reuse a consumed req.Body. Instead:
[]byte and set req.Body = io.NopCloser(bytes.NewReader(buf)) before each sendreq.GetBody so the transport can recreate the body for redirects/retries: req.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(buf)), nil }To duplicate a stream while reading, use io.TeeReader (copy to a buffer while passing through) or write to multiple sinks with io.MultiWriter
Reusing buffered readers: call (*bufio.Reader).Reset(r) to attach to a new underlying reader; do not expect it to “rewind” unless the source supports seeking
For large payloads, avoid unbounded buffering; consider streaming, io.LimitReader, or on-disk temporary storage to control memory
Use io.Pipe to stream without buffering the whole payload:
*io.PipeWriter in a separate goroutine while the reader consumesCloseWithError(err) on failuresio.Pipe is for streaming, not rewinding or making readers reusableWarning: When using io.Pipe (especially with multipart writers), all writes must be performed in strict, sequential order. Do not write concurrently or out of order—multipart boundaries and chunk order must be preserved. Out-of-order or parallel writes can corrupt the stream and result in errors.
Streaming multipart/form-data with io.Pipe:
pr, pw := io.Pipe(); mw := multipart.NewWriter(pw); use pr as the HTTP request bodyContent-Type to mw.FormDataContentType()mw in the correct order; on error pw.CloseWithError(err); on success mw.Close() then pw.Close()GetBodypprof)testing.B for benchmarks_test package suffix for black-box testing_test.go suffixTest_functionName_scenariot.Run for better organizationtestify or similar libraries when they add value, but don't over-complicate simple testst.Helper()testing.TB interface for functions used in tests and benchmarkst.Cleanup()go fmt: Format codego vet: Find suspicious constructsgolangci-lint: Additional linting (golint is deprecated)go test: Run testsgo mod: Manage dependenciesgo generate: Code generationany); prefer specific types or generic type parameters with constraints. If an unconstrained type is required, use any rather than interface{}package declarations - this is a compile error; always check existing files before adding package declarations© GitHub, Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com


Butterfly on Wheat at Golden Sunrise
Paints a classical oil painting of a butterfly resting on a golden wheat stalk in misty backlit sunrise light with dewdrop bokeh.
image-prompt, oil-painting, painting, classical-art, animals, flowers, landscape, golden-hour, bokeh, dramatic-lighting, soft-lighting, vertical-format, macro, dreamy, impressionism, fine-art, vibrant-colors, spring, for-artists, gpt-image, wallpaper, quick

Chibi character 16 frame dance reference sheet
Creates a square 4x4 sheet of sixteen consecutive dance keyframes of an uploaded character, following numbered choreography steps with identity locked and secondary motion on hair and cloth.
image-prompt, character-sheet, multi-panel, dance, chibi, reference-image, character-consistency, character-design, full-body, white-background, illustration, structured-output, square-format, negative-prompt, gpt-image, for-artists, for-designers, game-assets, long-form, advanced

Running Man Pulled Back by Semi Chibi Double
Makes a bright studio editorial photo of a running person from a reference photo, with a 3D semi-chibi double tugging their clothes back and realistic fabric tension.
image-prompt, gpt-image, reference-image, face-reference, negative-prompt, photorealistic, editorial, chibi, 3d-render, studio-lighting, white-background, fashion, portrait, full-body, motion-blur, whimsical, vertical-format, character-consistency, action-figure, fashion-shoot, pixar-style, soft-lighting, for-photographers, for-artists, humorous
Loading reviews…
Loading comments…