How does if condition works in golang


(Lutz Horn) #21

You could use Build Constraints to switch between implementations depending on the OS you build on.


(ravuri sai ram akhil) #22

Build is for files. Is there any thing for functions in the same way.


(Tamás Gulácsi) #23
  1. Create two files: db_windows.go and db_posix.go
  2. Then write the same functions in both files, differentiate only as the platforms need.
  3. profit. Only db_windows.go will be compiled on Windows and db_posix.go on Linux.

(ravuri sai ram akhil) #24

Thanks @Tamas_Gulacsi