Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Hardik180704/Go
/ functions
Functions
78 in github.com/Hardik180704/Go
⨍
Functions
78
◇
Types & classes
17
↓ 4 callers
Function
isEqual
isEqual uses COMPARABLE constraint [T comparable] means: "T can be ANY type that supports == and != operators" This is more restrictive than "any" Wor
Generics/main.go:26
↓ 3 callers
Method
Get
Get is a method on generic struct (c Container[T]) means this method works with Container of any type T
Generics/main.go:70
↓ 3 callers
Function
sumNumbers
(numbers []T)
Generics/main.go:53
↓ 2 callers
Function
MapKeys
MapKeys demonstrates using comparable with maps Maps require keys to be comparable types [K comparable, V any] means: Key must be comparable, Value ca
Generics/main.go:77
↓ 2 callers
Function
findMax
findMax uses UNION constraint (|) [T int | float64] means: "T can ONLY be int OR float64" The | symbol means "OR" - this is a type union This is more
Generics/main.go:36
↓ 2 callers
Method
getViews
()
Mutex/main.go:113
↓ 2 callers
Method
makePayment
makePayment is a method on the payment struct It uses whatever gateway was provided (razorpay, stripe, etc.) This is called "polymorphism" - same meth
Interfaces/main.go:22
↓ 2 callers
Function
printSlice
printSlice is a GENERIC function [T any] means: "T can be ANY type" - this is the generic type parameter Think of T as a placeholder that gets replace
Generics/main.go:13
↓ 1 callers
Method
Deposit
(amount int)
Mutex/main.go:226
↓ 1 callers
Method
GetBalance
()
Mutex/main.go:254
↓ 1 callers
Method
Withdraw
(amount int)
Mutex/main.go:237
↓ 1 callers
Function
add
Example of function to add two integers in Go
Functions/main.go:6
↓ 1 callers
Function
appendToFile
============================================ METHOD 7: Append to File ============================================ Add content WITHOUT deleting existi
File_Handling/main.go:379
↓ 1 callers
Function
bankDemo
()
Mutex/main.go:261
↓ 1 callers
Function
basicFileRead
============================================ METHOD 1: Basic File Reading (os.Open + Read) ============================================ This is the LO
File_Handling/main.go:135
↓ 1 callers
Function
basicFileWrite
============================================ METHOD 4: Basic File Writing ============================================ Low-level write with full contr
File_Handling/main.go:273
↓ 1 callers
Function
bufferedFileRead
============================================ METHOD 3: Buffered Reading (Line by Line) ============================================ BEST for large fil
File_Handling/main.go:221
↓ 1 callers
Function
bufferedFileWrite
============================================ METHOD 6: Buffered Writing ============================================ BEST for writing lots of data eff
File_Handling/main.go:341
↓ 1 callers
Function
changeNum
Function to change the value using pointer A pointer holds the memory address of a variable In this example, we pass the address of num to the functio
Pointers/main.go:8
↓ 1 callers
Function
changeOrderStatus
changeOrderStatus accepts only OrderStatus type This provides type safety - you can't pass any random string You must use one of the constants: Pendin
Enums/main.go:28
↓ 1 callers
Function
checkFileExists
============================================ METHOD 9: Check if File Exists ============================================ Idiom for checking existence
File_Handling/main.go:440
↓ 1 callers
Function
copyFile
============================================ METHOD 10: Copy Files ============================================ Copy one file to another
File_Handling/main.go:465
↓ 1 callers
Function
counter
Closure example in Go A closure is a function that captures the surrounding state Here, the counter function returns another function that increments
Closures/main.go:8
↓ 1 callers
Function
createDirectories
============================================ METHOD 13: Create Directories ============================================ Create single or nested direct
File_Handling/main.go:544
↓ 1 callers
Function
deleteFile
============================================ METHOD 12: Delete Files ============================================ Remove files or empty directories
File_Handling/main.go:525
↓ 1 callers
Function
emailWorker
emailWorker processes emails from the queue This simulates sending emails via SMTP server Multiple workers can run concurrently for better performance
Channels/main.go:199
↓ 1 callers
Function
filePermissions
============================================ METHOD 17: File Permissions ============================================ Change file permissions
File_Handling/main.go:693
↓ 1 callers
Function
fileSeek
============================================ METHOD 18: Seek (Random Access) ============================================ Move read/write position in
File_Handling/main.go:730
↓ 1 callers
Function
getFileInfo
============================================ METHOD 8: File Information (Stat) ============================================ Get metadata about a file
File_Handling/main.go:414
↓ 1 callers
Method
inc
()
Mutex/main.go:34
↓ 1 callers
Method
inc
()
Mutex/main.go:53
↓ 1 callers
Method
inc
()
Mutex/main.go:104
↓ 1 callers
Function
listDirectory
============================================ METHOD 14: List Directory Contents ============================================ Read files in a directory
File_Handling/main.go:576
↓ 1 callers
Function
moveFile
============================================ METHOD 11: Move/Rename Files ============================================ Move or rename file in one oper
File_Handling/main.go:504
↓ 1 callers
Function
nestedFunction
Nested function example
Functions/main.go:16
↓ 1 callers
Method
pay
(amount float64)
Interfaces/main.go:9
↓ 1 callers
Function
readEntireFile
============================================ METHOD 2: Read Entire File at Once ============================================ EASIEST method for small
File_Handling/main.go:187
↓ 1 callers
Function
receiver
receiver demonstrates receive-only channel
Channels/main.go:238
↓ 1 callers
Function
selectDemo
============================================ SELECT STATEMENT - MULTIPLEXING CHANNELS 🎛️ ============================================
Channels/main.go:251
↓ 1 callers
Function
sender
sender demonstrates send-only channel
Channels/main.go:226
↓ 1 callers
Function
sum
(nums ...int)
Variadic_Functions/main.go:5
↓ 1 callers
Function
swap
Example function to return multiple values
Functions/main.go:11
↓ 1 callers
Function
task
task is a simple function that prints a task ID This will be executed concurrently using goroutines Each task runs independently and can execute in pa
Wait_Groups/main.go:12
↓ 1 callers
Function
task
task is a simple function that prints a task ID This will be executed concurrently using goroutines Each task runs independently and can execute in pa
Goroutines/main.go:11
↓ 1 callers
Function
temporaryFiles
============================================ METHOD 16: Temporary Files ============================================ Create files that auto-delete (us
File_Handling/main.go:653
↓ 1 callers
Function
walkDirectory
============================================ METHOD 15: Walk Directory Tree ============================================ Recursively traverse director
File_Handling/main.go:609
↓ 1 callers
Function
writeEntireFile
============================================ METHOD 5: Write Entire File at Once ============================================ EASIEST method for writi
File_Handling/main.go:315
Function
GetSession
()
Packages/auth/session.go:3
Function
LoginWithCredentials
(username, password string)
Packages/auth/credentials.go:5
Function
deadlockDemo
============================================ SELECT STATEMENT KEY CONCEPTS 🎯 ============================================ WHAT IS SELECT? - Like a sw
Channels/main.go:476
Method
getViews
Read operation also needs mutex if writes are happening
Mutex/main.go:79
Method
incSafe
Better pattern: Use defer to ensure Unlock happens even if panic occurs
Mutex/main.go:71
Function
main
()
Generics/main.go:85
Function
main
()
Wait_Groups/main.go:21
Function
main
============================================ MAIN FUNCTION - PROGRAM ENTRY POINT ============================================ func main() is where pro
Packages/main.go:52
Function
main
()
If_Else/main.go:3
Function
main
()
Interfaces/main.go:47
Function
main
()
Arrays/main.go:5
Function
main
()
Simple_Values/main.go:5
Function
main
============================================ DEMONSTRATION: Race Condition vs Mutex ============================================
Mutex/main.go:126
Function
main
for -> only construct in go for looping
For_Loop/main.go:6
Function
main
()
Structs/main.go:12
Function
main
()
Maps/main.go:9
Function
main
()
Constants/main.go:5
Function
main
()
Enums/main.go:32
Function
main
()
Goroutines/main.go:15
Function
main
============================================ FILE HANDLING IN GO - COMPLETE GUIDE 📁 ============================================ Go provides multiple
File_Handling/main.go:18
Function
main
()
Slices/main.go:8
Function
main
()
Pointers/main.go:13
Function
main
()
Hello_World/main.go:5
Function
main
()
Switch/main.go:3
Function
main
()
Closures/main.go:16
Function
main
()
Variables/main.go:5
Function
main
()
Channels/main.go:49
Function
main
()
Variadic_Functions/main.go:13
Function
main
()
Functions/main.go:20
Method
pay
pay method implements the paymenter interface for razorpay This means razorpay "satisfies" the paymenter interface In Go, you don't need to explicitly
Interfaces/main.go:34
Method
pay
pay method implements the paymenter interface for stripe Same method name and signature as razorpay, but different implementation
Interfaces/main.go:43