SlideShare a Scribd company logo
1 of 19
Developing Cross Platform
Application
Erhan Yakut / @yakuter
Ankara Gophers #4 / 18 February 2021
Programlama Dilleri
Aktif olarak Go ile geliştirme yapmakla
birlikte uzun yıllar PHP backend
developer olarak proje geliştirdim.
İletişim Bilgisi
Eposta : yakuter@gmail.com
Twitter: @yakuter
İş / Görev
Binalyze isimli Enterprise Forensics
yazılım şirketinde Senior Software
Architect olarak çalışmaktayım.
Tecrübe/Bilgi
Yaklaşık 15+ yıldır yazılım geliştirme ile
ilgilenmekte olup, şu anda işletim
sistemleri üzerinde olay sonrası delillerin
toplanması için yazılım geliştirmekteyim.
Erhan YAKUT
(yakuter)
Biyografi
Ben Kimim?
Golang Cross Platform Support
Cross Platform with Golang
The Go language was designed to be a systems language usable across
multiple platforms. It has a number of built-in language and build features
that make it ideal for easy cross-platform development.
https://pkg.go.dev/cmd/go#section-documentation
Interface Logic
Interfaces
Abstract all platform specifics behind interfaces.
https://cs.opensource.google/go/go/+/master:src/os/exec.go
https://techblog.steelseries.com/2014/04/08/multi-platform-development-go.html
Build Constraints
Build Constraints
Build constraints are a language construct that can be used to control the
platforms and architectures on which a file will be compiled. They come in
two flavors:
1. Filename-based
<name>[_GOOS][_GOARCH].<extension>
2. Comment at top of file
Commas = AND
Spaces = OR
//go:build (linux && 386) || (darwin && !cgo)
// +build linux,386 darwin,!cgo
-> go tool dist list
-> go tool dist list -json
-> https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
Cross Compilation
Cross Compilation
Because of some non-Go pieces (library and drivers), we avoid doing this.
set GOOS=windows
set GOARCH=386
go build .
CGO
sudo apt-get install gcc-multilib
sudo apt-get install gcc-mingw-w64
-> GOOS=windows GOARCH=386 CGO_ENABLED=1 CXX=i686-w64-mingw32-g++ CC=i686-w64-
mingw32-gcc go build
https://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5
Syscall
What is System Call in Operating System?
In computing, a system call (commonly abbreviated to syscall) is the programmatic way
in which a computer program requests a service from the kernel of the operating system
on which it is executed.
https://www.guru99.com/system-call-operating-system.html
Types of System calls
Here are the five types of System Calls in OS:
1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communications
Syscall
Shutdown, Reboot
Linux
syscall.Reboot(
syscall.LINUX_REBOOT_CMD_POWER_OFF,
)
Windows
windows.ExitWindowsEx(
windows.EWX_POWEROFF,
windows.SHTDN_REASON_MAJOR_APPLICATI
ON,
)
https://cs.opensource.google/go/x/sys/+/3b038e59:windows/z
syscall_windows.go;l=3773
seShutdownName = "SeShutdownPrivilege"
https://docs.microsoft.com/en-
us/windows/win32/shutdown/how-to-shut-down-the-system
Hostname
Linux
hostname, err := os.Hostname()
Windows
hostname, err := os.Hostname()
windows.GetComputerNameEx()
----
syscall.ComputerName()
GetComputerName retrieves only the NetBIOS name of the
local computer. To retrieve the DNS host name, DNS domain
name, or the fully qualified DNS name, call the
GetComputerNameEx function.
https://docs.microsoft.com/en-
us/windows/win32/api/winbase/nf-winbase-
getcomputernamew
https://cs.opensource.google/go/x/sys/+/03aa0b5f:windows/s
yscall_windows.go;drc=94396e421777fa1601dc71542cd5cb0c6
7fe4664;l=211
Filesystem Behaviour
Works in Linux / Fails in Windows
file, _ := os.Open(“/home/user/test.log”)
_ = os.Remove(file.Name())
You should first close the file, then remove in Windows.
Filesystem Redirection
What is Windows Filesystem Redirection?
On 64-bit Windows operating systems the %WINDIR%system32 directory is reserved
for 64-bit applications and by default any attempt by a 32-bit application to reference
the %WINDIR%system32 directory will be redirected to the %WINDIR%SysWow64
directory.
Disable Filesystem Redirection
pWow64Disable = kernel32.NewProc("Wow64DisableWow64FsRedirection")
pWow64Revert = kernel32.NewProc("Wow64RevertWow64FsRedirection")
Windows API
What is Windows Filesystem Redirection
Windows APIs are published via DLLs delivered with each installation of the
Windows OS.
https://docs.microsoft.com/en-us/windows/win32/apiindex/api-index-portal
To Load a DLL in Go, you can use syscall.NewLazyDLL or syscall.LoadLibrary .
After the DLL is loaded (or lazy-loaded), you then must get a reference to the the
Procedure using dll.NewProc("ProcName") .
var (
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
procOpenProcess = kernel32DLL.NewProc("OpenProcess")
)
Windows API
Registry
Windows Registry
The Windows Registry is a hierarchical database that stores low-level
settings for the Microsoft Windows operating system and for
applications that opt to use the registry. The kernel, device drivers,
services, Security Accounts Manager, and user interfaces can all use the
registry.
Signals
What is Signals?
Signals are software interrupts sent to a program to indicate that an
important event has occurred. The events can vary from user requests
to illegal memory access errors. Some signals, such as the interrupt
signal, indicate that a user has asked the program to do something
that is not in the usual flow of control. Examples:
SIGINT, SIGKILL, SIGTERM
Signals
Signal in Windows
var hevent windows.Handle
hevent, _ = windows.CreateEvent(nil, 0, 0, nil)
---
windows.SetEvent(e.handle)
--
syscall.WaitForSingleObject(hevent, syscall.INFINITE)
https://pkg.go.dev/golang.org/x/sys/windows
https://docs.microsoft.com/en-us/cpp/c-runtime-
library/reference/signal?view=msvc-170
Useful Links
Go Spec
https://go.dev/ref/spec
Effective Go
https://go.dev/doc/effective_go
Github Go Wiki
https://github.com/golang/go/wiki
Go Code Review Comments
https://github.com/golang/go/wiki/CodeReviewComments
Thank You

More Related Content

What's hot

Golang for PHP programmers: A practical introduction
Golang for PHP programmers: A practical introductionGolang for PHP programmers: A practical introduction
Golang for PHP programmers: A practical introductionRichard Tuin
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
Come With Golang
Come With GolangCome With Golang
Come With Golang尚文 曾
 
Wonders of Golang
Wonders of GolangWonders of Golang
Wonders of GolangKartik Sura
 
Docker introduction in Hardware Company
Docker introduction in Hardware CompanyDocker introduction in Hardware Company
Docker introduction in Hardware CompanyEvan Lin
 
Golang from Scala developer’s perspective
Golang from Scala developer’s perspectiveGolang from Scala developer’s perspective
Golang from Scala developer’s perspectiveSveta Bozhko
 
13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applicationsKarthik Gaekwad
 
Golang start and tips
Golang start and tipsGolang start and tips
Golang start and tipsAaron King
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
 
用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務Bo-Yi Wu
 
Inroduction to golang
Inroduction to golangInroduction to golang
Inroduction to golangYoni Davidson
 
Go from PHP engineer's perspective
Go from PHP engineer's perspectiveGo from PHP engineer's perspective
Go from PHP engineer's perspectiveSobit Akhmedov
 
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Aniruddha Chakrabarti
 
welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?sangam biradar
 
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.aviSeongJae Park
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneVincenzo Barone
 
Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)Aaron Schlesinger
 
An introduction to_golang.avi
An introduction to_golang.aviAn introduction to_golang.avi
An introduction to_golang.aviSeongJae Park
 
kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs sangam biradar
 

What's hot (20)

Golang for PHP programmers: A practical introduction
Golang for PHP programmers: A practical introductionGolang for PHP programmers: A practical introduction
Golang for PHP programmers: A practical introduction
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
Come With Golang
Come With GolangCome With Golang
Come With Golang
 
Wonders of Golang
Wonders of GolangWonders of Golang
Wonders of Golang
 
Docker introduction in Hardware Company
Docker introduction in Hardware CompanyDocker introduction in Hardware Company
Docker introduction in Hardware Company
 
Golang from Scala developer’s perspective
Golang from Scala developer’s perspectiveGolang from Scala developer’s perspective
Golang from Scala developer’s perspective
 
13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications13 practical tips for writing secure golang applications
13 practical tips for writing secure golang applications
 
Golang start and tips
Golang start and tipsGolang start and tips
Golang start and tips
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務
 
Inroduction to golang
Inroduction to golangInroduction to golang
Inroduction to golang
 
Go from PHP engineer's perspective
Go from PHP engineer's perspectiveGo from PHP engineer's perspective
Go from PHP engineer's perspective
 
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
 
welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?welcome to gopherlabs - why go (golang)?
welcome to gopherlabs - why go (golang)?
 
(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi(Live) build and run golang web server on android.avi
(Live) build and run golang web server on android.avi
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind Plone
 
Why you should care about Go (Golang)
Why you should care about Go (Golang)Why you should care about Go (Golang)
Why you should care about Go (Golang)
 
TYPO3 & Composer
TYPO3 & ComposerTYPO3 & Composer
TYPO3 & Composer
 
An introduction to_golang.avi
An introduction to_golang.aviAn introduction to_golang.avi
An introduction to_golang.avi
 
kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs kikstart journey of Golang with Hello world - Gopherlabs
kikstart journey of Golang with Hello world - Gopherlabs
 

Similar to Developing Cross Platform Apps with Golang

Betabeers Android as a Digital Signage platform
Betabeers   Android as a Digital Signage platformBetabeers   Android as a Digital Signage platform
Betabeers Android as a Digital Signage platformOrestes Carracedo
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidVlatko Kosturjak
 
Iz Pack
Iz PackIz Pack
Iz PackInria
 
Developing FirefoxOS
Developing FirefoxOSDeveloping FirefoxOS
Developing FirefoxOSFred Lin
 
Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Codemotion
 
Android Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoTAndroid Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoTinovex GmbH
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Asher Martin
 
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808Cisco DevNet
 
OpenSouthCode 2016 - Accenture DevOps Platform 2016-05-07
OpenSouthCode 2016  - Accenture DevOps Platform 2016-05-07OpenSouthCode 2016  - Accenture DevOps Platform 2016-05-07
OpenSouthCode 2016 - Accenture DevOps Platform 2016-05-07Jorge Hidalgo
 
Firefox OS - Hive Pilani 2015
Firefox OS - Hive Pilani 2015Firefox OS - Hive Pilani 2015
Firefox OS - Hive Pilani 2015Nilay Binjola
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment TacticsIan Barber
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with PythonBrian Lyttle
 
DomDisc and the Domino data api
DomDisc and the Domino data apiDomDisc and the Domino data api
DomDisc and the Domino data apiJens Bruntt
 
Developing multi-screen applications using Adobe Integrated Runtime (AIR)
Developing multi-screen applications using Adobe Integrated Runtime (AIR)Developing multi-screen applications using Adobe Integrated Runtime (AIR)
Developing multi-screen applications using Adobe Integrated Runtime (AIR)Sujit Reddy G
 
Orchestrated Android-Style System Upgrades for Embedded Linux
Orchestrated Android-Style System Upgrades for Embedded LinuxOrchestrated Android-Style System Upgrades for Embedded Linux
Orchestrated Android-Style System Upgrades for Embedded LinuxKynetics
 
Orchestrated Android-Style System Upgrades for Embedded Linux
Orchestrated Android-Style System Upgrades for Embedded LinuxOrchestrated Android-Style System Upgrades for Embedded Linux
Orchestrated Android-Style System Upgrades for Embedded LinuxNicolaLaGloria
 
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
Linux Security  and How Web Browser Sandboxes Really Work (NDC Oslo 2017)Linux Security  and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)Patricia Aas
 

Similar to Developing Cross Platform Apps with Golang (20)

Betabeers Android as a Digital Signage platform
Betabeers   Android as a Digital Signage platformBetabeers   Android as a Digital Signage platform
Betabeers Android as a Digital Signage platform
 
Porting your favourite cmdline tool to Android
Porting your favourite cmdline tool to AndroidPorting your favourite cmdline tool to Android
Porting your favourite cmdline tool to Android
 
Ankur_Srivastava
Ankur_SrivastavaAnkur_Srivastava
Ankur_Srivastava
 
Iz Pack
Iz PackIz Pack
Iz Pack
 
Installers
InstallersInstallers
Installers
 
Developing FirefoxOS
Developing FirefoxOSDeveloping FirefoxOS
Developing FirefoxOS
 
Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017
 
Php On Windows
Php On WindowsPhp On Windows
Php On Windows
 
Android Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoTAndroid Embedded - Smart Hubs als Schaltzentrale des IoT
Android Embedded - Smart Hubs als Schaltzentrale des IoT
 
Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3Cape Cod Web Technology Meetup - 3
Cape Cod Web Technology Meetup - 3
 
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
Golang 101 for IT-Pros - Cisco Live Orlando 2018 - DEVNET-1808
 
OpenSouthCode 2016 - Accenture DevOps Platform 2016-05-07
OpenSouthCode 2016  - Accenture DevOps Platform 2016-05-07OpenSouthCode 2016  - Accenture DevOps Platform 2016-05-07
OpenSouthCode 2016 - Accenture DevOps Platform 2016-05-07
 
Firefox OS - Hive Pilani 2015
Firefox OS - Hive Pilani 2015Firefox OS - Hive Pilani 2015
Firefox OS - Hive Pilani 2015
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment Tactics
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
DomDisc and the Domino data api
DomDisc and the Domino data apiDomDisc and the Domino data api
DomDisc and the Domino data api
 
Developing multi-screen applications using Adobe Integrated Runtime (AIR)
Developing multi-screen applications using Adobe Integrated Runtime (AIR)Developing multi-screen applications using Adobe Integrated Runtime (AIR)
Developing multi-screen applications using Adobe Integrated Runtime (AIR)
 
Orchestrated Android-Style System Upgrades for Embedded Linux
Orchestrated Android-Style System Upgrades for Embedded LinuxOrchestrated Android-Style System Upgrades for Embedded Linux
Orchestrated Android-Style System Upgrades for Embedded Linux
 
Orchestrated Android-Style System Upgrades for Embedded Linux
Orchestrated Android-Style System Upgrades for Embedded LinuxOrchestrated Android-Style System Upgrades for Embedded Linux
Orchestrated Android-Style System Upgrades for Embedded Linux
 
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
Linux Security  and How Web Browser Sandboxes Really Work (NDC Oslo 2017)Linux Security  and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 

Developing Cross Platform Apps with Golang

  • 1. Developing Cross Platform Application Erhan Yakut / @yakuter Ankara Gophers #4 / 18 February 2021
  • 2. Programlama Dilleri Aktif olarak Go ile geliştirme yapmakla birlikte uzun yıllar PHP backend developer olarak proje geliştirdim. İletişim Bilgisi Eposta : yakuter@gmail.com Twitter: @yakuter İş / Görev Binalyze isimli Enterprise Forensics yazılım şirketinde Senior Software Architect olarak çalışmaktayım. Tecrübe/Bilgi Yaklaşık 15+ yıldır yazılım geliştirme ile ilgilenmekte olup, şu anda işletim sistemleri üzerinde olay sonrası delillerin toplanması için yazılım geliştirmekteyim. Erhan YAKUT (yakuter) Biyografi Ben Kimim?
  • 3. Golang Cross Platform Support Cross Platform with Golang The Go language was designed to be a systems language usable across multiple platforms. It has a number of built-in language and build features that make it ideal for easy cross-platform development. https://pkg.go.dev/cmd/go#section-documentation
  • 4. Interface Logic Interfaces Abstract all platform specifics behind interfaces. https://cs.opensource.google/go/go/+/master:src/os/exec.go https://techblog.steelseries.com/2014/04/08/multi-platform-development-go.html
  • 5. Build Constraints Build Constraints Build constraints are a language construct that can be used to control the platforms and architectures on which a file will be compiled. They come in two flavors: 1. Filename-based <name>[_GOOS][_GOARCH].<extension> 2. Comment at top of file Commas = AND Spaces = OR //go:build (linux && 386) || (darwin && !cgo) // +build linux,386 darwin,!cgo -> go tool dist list -> go tool dist list -json -> https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63
  • 6. Cross Compilation Cross Compilation Because of some non-Go pieces (library and drivers), we avoid doing this. set GOOS=windows set GOARCH=386 go build . CGO sudo apt-get install gcc-multilib sudo apt-get install gcc-mingw-w64 -> GOOS=windows GOARCH=386 CGO_ENABLED=1 CXX=i686-w64-mingw32-g++ CC=i686-w64- mingw32-gcc go build https://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5
  • 7. Syscall What is System Call in Operating System? In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the kernel of the operating system on which it is executed. https://www.guru99.com/system-call-operating-system.html Types of System calls Here are the five types of System Calls in OS: 1. Process Control 2. File Management 3. Device Management 4. Information Maintenance 5. Communications
  • 10. Hostname Linux hostname, err := os.Hostname() Windows hostname, err := os.Hostname() windows.GetComputerNameEx() ---- syscall.ComputerName() GetComputerName retrieves only the NetBIOS name of the local computer. To retrieve the DNS host name, DNS domain name, or the fully qualified DNS name, call the GetComputerNameEx function. https://docs.microsoft.com/en- us/windows/win32/api/winbase/nf-winbase- getcomputernamew https://cs.opensource.google/go/x/sys/+/03aa0b5f:windows/s yscall_windows.go;drc=94396e421777fa1601dc71542cd5cb0c6 7fe4664;l=211
  • 11. Filesystem Behaviour Works in Linux / Fails in Windows file, _ := os.Open(“/home/user/test.log”) _ = os.Remove(file.Name()) You should first close the file, then remove in Windows.
  • 12. Filesystem Redirection What is Windows Filesystem Redirection? On 64-bit Windows operating systems the %WINDIR%system32 directory is reserved for 64-bit applications and by default any attempt by a 32-bit application to reference the %WINDIR%system32 directory will be redirected to the %WINDIR%SysWow64 directory. Disable Filesystem Redirection pWow64Disable = kernel32.NewProc("Wow64DisableWow64FsRedirection") pWow64Revert = kernel32.NewProc("Wow64RevertWow64FsRedirection")
  • 13. Windows API What is Windows Filesystem Redirection Windows APIs are published via DLLs delivered with each installation of the Windows OS. https://docs.microsoft.com/en-us/windows/win32/apiindex/api-index-portal To Load a DLL in Go, you can use syscall.NewLazyDLL or syscall.LoadLibrary . After the DLL is loaded (or lazy-loaded), you then must get a reference to the the Procedure using dll.NewProc("ProcName") . var ( kernel32DLL = syscall.NewLazyDLL("kernel32.dll") procOpenProcess = kernel32DLL.NewProc("OpenProcess") )
  • 15. Registry Windows Registry The Windows Registry is a hierarchical database that stores low-level settings for the Microsoft Windows operating system and for applications that opt to use the registry. The kernel, device drivers, services, Security Accounts Manager, and user interfaces can all use the registry.
  • 16. Signals What is Signals? Signals are software interrupts sent to a program to indicate that an important event has occurred. The events can vary from user requests to illegal memory access errors. Some signals, such as the interrupt signal, indicate that a user has asked the program to do something that is not in the usual flow of control. Examples: SIGINT, SIGKILL, SIGTERM
  • 17. Signals Signal in Windows var hevent windows.Handle hevent, _ = windows.CreateEvent(nil, 0, 0, nil) --- windows.SetEvent(e.handle) -- syscall.WaitForSingleObject(hevent, syscall.INFINITE) https://pkg.go.dev/golang.org/x/sys/windows https://docs.microsoft.com/en-us/cpp/c-runtime- library/reference/signal?view=msvc-170
  • 18. Useful Links Go Spec https://go.dev/ref/spec Effective Go https://go.dev/doc/effective_go Github Go Wiki https://github.com/golang/go/wiki Go Code Review Comments https://github.com/golang/go/wiki/CodeReviewComments