Skip to content

Instantly share code, notes, and snippets.

View sagar23sj's full-sized avatar
🎯
Focusing

Sagar Sonwane sagar23sj

🎯
Focusing
View GitHub Profile
# Name of workflow to be displyed on Github Console
name: Build and Test Go Application
# Triggers the workflow on separate events
on:
push:
# Trigger the worflow on push event for all branches
branches:
- '**'
pull_request:
# Name of workflow to be displyed on Github Console
name: Build and Test Go Application
# Triggers the workflow on separate events
on:
push:
# Trigger the worflow on push event for all branches
branches:
- '**'
pull_request:
@sagar23sj
sagar23sj / exported_1_counter.go
Created August 30, 2021 08:25
Example - Exported Identifiers in Golang - counter.go
package counter
// Count is an exported identifier of integer type
type Count int
@sagar23sj
sagar23sj / unexported_counter.go
Last active August 30, 2021 09:07
Example - Unexported Identifier in Golang
package counter
// internalCounter is an unexported identifier of integer type
type internalCounter int
@sagar23sj
sagar23sj / exported_2_counter.go
Last active August 30, 2021 09:07
Example - Exported function for Unexported type
package counter
// internalCounter is an unexported identifier of integer type
type internalCounter int
// NewInternalCounter creates an object of internalCounter
// with value passed to it and returns
// an object of type internalCounter
func NewInternalCounter(val int) internalCounter {
return internalCounter(val)
@sagar23sj
sagar23sj / unexported_field_1_employee.go
Last active August 30, 2021 11:23
Example - unexported field in struct
package employee
//Exported struct type Employee with employee details
type Employee struct {
Name string
Age int
salary float64
}
@sagar23sj
sagar23sj / exported_method_employee.go
Last active August 30, 2021 11:55
Example - unexported field in struct
package employee
//Exported struct type Employee with employee details
type Employee struct {
Name string
Age int
salary float64
}
func (e *Employee) SetSalary(val float64) {
@sagar23sj
sagar23sj / exported_1_animal.go
Last active August 30, 2021 12:23
Example - exported type Dog with embedded struct
package animal
//Exported type struct
type Animal struct {
Name string
}
//Exported type Dog embedding type Animal
type Dog struct {
Animal
@sagar23sj
sagar23sj / unexported_animal.go
Created August 30, 2021 12:35
Unexported animal type in animal package
package animal
//Unexported type struct
type animal struct {
Name string
}
//Exported type Dog embedding type Animal
type Dog struct {
animal
@sagar23sj
sagar23sj / updated_main.go
Created August 30, 2021 12:42
Updated main.go for unexported embedded struct
package main
import (
"fmt"
"github.com/sagar23sj/Go-OOP/Encapsulation/animal"
)
func main() {
//Creating an object of type Dog from animal package