gobox_utils

package module
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 14 Imported by: 0

README

gobox

Handy Go tools and snippets I use across multiple projects — extracted, cleaned up, and shared.

git client gh workflow run "Go Test & Versioning" -f release_type=minor

go test go test -v

go test -cover go test -bench=. go test -coverprofile=coverage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchRepoFolders

func FetchRepoFolders(opts GitFetchOptions) error

FetchRepoFolders fetches and downloads specified folders from a GitHub repo

func StartTerminalStream added in v0.4.2

func StartTerminalStream(containerName string, ctx context.Context) error

func WriteToTerminal added in v0.4.2

func WriteToTerminal(input string) error

Types

type DirToJSONOptions added in v0.4.2

type DirToJSONOptions struct {
	PrintJSON bool // If true, print the resulting JSON to stdout
}

DirToJSONOptions defines optional parameters for DirToJSON.

type FileNode

type FileNode struct {
	Name     string      `json:"name"`               // The name of the file or directory
	IsDir    bool        `json:"isDir"`              // True if this node is a directory
	Children []*FileNode `json:"children,omitempty"` // Child nodes (only if IsDir is true)
}

FileNode represents a single file or directory in a hierarchical structure. It will be serialized into JSON.

func DirToJSON

func DirToJSON(root string, options *DirToJSONOptions) (*FileNode, error)

DirToJSON converts a directory structure into a tree of FileNode objects. It recursively scans the given root directory and builds a tree representation, which can be serialized into JSON.

Parameters:

  • root: string — The full path of the directory or file to scan.
  • options: optional settings (e.g., PrintJSON)

Returns:

  • *FileNode — A pointer to the root FileNode struct representing the file or folder hierarchy.
  • error — An error if something went wrong while accessing the filesystem.

Example:

Calling DirToJSON("myfolder") might output:
{
  "name": "myfolder",
  "isDir": true,
  "children": [
    {
      "name": "file1.txt",
      "isDir": false
    },
    {
      "name": "subdir",
      "isDir": true,
      "children": [
        {
          "name": "nested.txt",
          "isDir": false
        }
      ]
    }
  ]
}

type GitFetchOptions

type GitFetchOptions struct {
	RepoURL         string
	Branch          string
	DestinationPath string
	Folders         []string
	PullOnlyFolders bool
	Overwrite       bool
	OnProgress      ProgressHandler
}

GitFetchOptions defines options for fetching a GitHub repository

type ProgressHandler

type ProgressHandler func(progress int, message string)

type TerminalSession added in v0.4.2

type TerminalSession struct {
	IsActive bool
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL